Difference between revisions of "Cat"

From Linuxintro
imported>ThorstenStaerk
m (Cat)
imported>ThorstenStaerk
 
Line 25: Line 25:
  
 
= See also =
 
= See also =
 +
* [[shell skripting tutorial]]
 
* [[tac]]
 
* [[tac]]
 
* [[rev]]
 
* [[rev]]

Latest revision as of 21:50, 4 January 2012

cat is a powerful tool that prints the content of a file.

However cat is integrated into the Unix philosophy and is not limited to this. On a more general level, cat reads and prints what it reads.

Exploring the concept

To understand how cat works, open a console. If you just type

cat

cat will read from the standard input (the keyboard) and print to standard output (the console).

If you type

cat file

cat will read from (a file named) file and print to standard output (the console).

If you type

cat >file

cat will read from standard input (the keyboard) and write the input to (a file named) file. You can tell the system that you have finished your input using the key combination CTRL_D.

If you type

cat >> file

cat will read from standard input (the keyboard) and append the input to (a file named) file. You can tell the system that you have finished your input using the key combination CTRL_D.

If you type

cat >> file << EOF

cat will read from standard input (the keyboard) and append the input to (a file named) file. It will continue to read till it encounters the input line EOF.

See also