Difference between revisions of "Cat"
imported>ThorstenStaerk |
imported>ThorstenStaerk m (Cat) |
||
Line 30: | Line 30: | ||
* [[piping]] | * [[piping]] | ||
* [[stdout, stderr and stdin]] | * [[stdout, stderr and stdin]] | ||
+ | |||
+ | [[Category:Command]] |
Revision as of 13:03, 22 December 2011
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.