show file content | cat cheat-sheet
What is ‘cat’ ? π
cat is one of the GNU core utils. It is used to print and concatenate files.
There are 2 versions of cat program. The first is GNU cat, and the other is POSIX-compliant cat.
Common usage available in GNU cat and POSIX cat π
Print the contents of a file to the standard output (a.k.a. stdout):
cat path/to/file
Concatenate several files into an output file:
cat path/to/file1 path/to/file2 ... > path/to/output_file
Append several files to an output file:
cat path/to/file1 path/to/file2 ... >> path/to/output_file
Copy the contents of a file into an output file without buffering:
cat -u /dev/tty12 > /dev/tty13
Write the standard input (a.k.a. stdin) to a file:
cat - > path/to/file
Features available ONLY in GNU cat π
Number all output lines:
cat [-n|--number] path/to/file
Display non-printable and whitespace characters (with M-
prefix if non-ASCII):
cat [-vte|--show-nonprinting -t -e] path/to/file
For more information, checkout the official documentation: https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html , or here https://manned.org/cat.1posix .
I hope you enjoyed reading this post as much as I enjoyed writing it. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .