Cat Command – UNIX

Cat Command UNIX

Description

cat is short of Concatenate..

The cat command reads one or more files or standard input and prints them to standard output. It is also used to print all the content of the file on terminal.

The operator > can be used to combine multiple files into one. The operator >> can be used to append to an existing file.

Options

Following options can be used with the cd command:

-A, –show-all equivalent to -vET
-b, –number-nonblank number nonempty output lines, overrides -n
-e equivalent to -vE
-E, –show-ends display $ at end of each line
-n, –number number all output lines
-s, –squeeze-blank suppress repeated empty output lines
-t equivalent to -vT
-T, –show-tabs display TAB characters as ^I
-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

Example 1:

Print all the content of the file on terminal.

$ cat CF0001.dat
$9555777241:9841723417:20160318:20:Rupees
55777242:9841723418:20160318:25:Dollar
5777243:9841723419:20160318:18:Rupees
777243:9841723419:20160318:30:Rupees
77243:9841723419:20160318:50:Pound

Example 2:

Check if the content of the files contains any Control Characters

$ cat -v CF0001.dat
$9555777241:9841723417:20160318:20:Rupees^M
55777242:9841723418:20160318:25:Dollar^M
5777243:9841723419:20160318:18:Rupees^M
777243:9841723419:20160318:30:Rupees^M
77243:9841723419:20160318:50:Pound^M

Example 3:

Merge content of 2 files in one

$ cat CF0001.dat CF0002.dat > CF_merge.dat
$