Monday, February 14, 2011

cat linux command

The cat command's primary function is to concatenate, or join, files, but you can also use it to display a file on the screen. The cat command takes one or more files that you specify, smashes them together, and then sends the resulting file to the standard output device (without changing any of the original files). The standard output device is your screen, but by using the greater-than (>) operator, you can redirect cat's output to another file. 


Syntax :


cat [option] [file name]


Options :
      -A, --show-all
              equivalent to -vET


       -b, --number-nonblank
              number nonblank output lines


       -e     equivalent to -vE


       -E, --show-ends
              display $ at end of each line


       -n, --number
              number all output lines


       -s, --squeeze-blank
              never more than one single blank line


       -t     equivalent to -vT


       -T, --show-tabs
              display TAB characters as ^I


       -u     (ignored)


       -v, --show-nonprinting
              use ^ and M- notation, except for LFD and TAB


       --help display this help and exit


       --version
              output version information and exit



Examples:



cat test.txt
Display the test.txt file on the screen.

cat test1.txt test2.txt
Join the files test1.txt and test2.txt and then displayt he result on the screen.

cat test1.txt test2.txt > test3.txt
Join the files test1.txt and test2.txt and save them in the file test3.txt.


No comments:

Post a Comment