Cat

From Linuxintro
Revision as of 09:02, 4 June 2010 by imported>ThorstenStaerk (→‎Exploring the concept)

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