Linux create file -How to view and edit file in Linux/Uinx using Terminal

Linux / Unix operating system provide many command line
tools and text editors for creating single or multiple text files ( linux create file ). We can use
gedit, vi/vim text editor. It is a terminal based text editor in Linux/ Unix
Systems, available under the GPL.  There are many, many text editors available for linux create file and it is designed to be easy to use.
These are follows.
linux create file
  •   Cat command
  •    Touch command
  •    Echo or printf command
  •    Vi/vim editor
  •    Gedit editor


Now we see only commands
Create a Text file using cat command
  • Cat (concatenate) command is used to linux create file and to
    display and modify the contents of file


To Linux Create file
# cat > filename ( say file1)
Hello world
Press CTRL+D  to save a file
[root@rahul ~]# cat > file1
Hello World
To display the
content of the file
# cat filename
[root@rahul ~]# cat file1
Hello World
[root@rahul ~]#
To append the data in already existing file
# cat >>
# cat >> file1
Ctrl+d  (to save the
[root@rahul ~]# cat >> file1
Welcome to linux
[root@rahul ~]#
Creating multiple empty  files at the same time using touch
# touch <filename> <filename> <filename>
# touch file1 file2 file3 file4
Note:  For Check the
files use # ls command
[root@rahul ~]# touch file1 file2 file3 file4
[root@rahul ~]# ls
4raj                         file1        install.log.syslog  ktfile.softlink  raj
anaconda-ks.cfg     file2         kernal              Music            ram
Desktop                  file3        ktdir               Pictures         songs
Documents             file4
ktfile              Public           Templates
Create a text file using echo or printf
# echo ‘Hello World’ > filename
[root@rahul ~]# echo ‘Hello world’ > file1
# printf  ‘Hello world’
> filename
[root@rahul ~]# printf ‘Hello worldn’ > file1
# printf  ‘Hello World
n Another line’ > filename
[root@rahul ~]# printf ‘Hello worldn another line ‘ > file1
To display the file contents, type:
[root@rahul ~]# cat file1


One thought on “Linux create file -How to view and edit file in Linux/Uinx using Terminal”

  1. Hi There! We are searching for experienced people that are interested in from working their home on a part-time basis. If you want to earn $200 a day, and you don’t mind creating some short opinions up, this is the perfect opportunity for you! Simply click the link here NOW!

Leave a Reply

Your email address will not be published. Required fields are marked *