cat command in Linux with syntax and example

Cat command in Linux with example.

cat command in Linux

cat : cat  command is used to create ,red and modify the file.
  • To create a file
    • Syntax : cat  >  <file name>
    • Example : cat  >  test.txt
      Hello World
      Ctrl+d (To save and exit the file)

  • To Red the file
    • Syntax : cat <file name>
    • Example : cat test.txt
      Hello World
  • To Modify the file.
    • Syntax : cat  >>  <file name >
    • Example : cat  >> test.txt
      Hello World 1
      Ctrl+d (To save and exit the file)
  • To see contents of file in line by line.
    • Syntax : cat -n <file name>
    • Example : cat -n test.txt
          1 Hello World
          2 Hello World 1
     This video for cat command in Linux with examples
  • Note :  If you using single > singe the cat command will delete previous  data and add new data.
  • To see contents of two or more then two file with cat command.
    • Syntax : cat  <file name>  <file name>
    • Example : cat  test.txt  test1.txt

  • Use less with cat command.
    • Syntax : cat  <file name> | less
    • Example : cat  test.txt |  less

  • Use More with cat command.
    • Syntax : cat   <file name> | more
    • Example : cat  test.txt |more.
mukesh.thakur87: