Getting older, not necessarily wiser!
The cat (short for concatenate) command is a standard utility command in Linux Distributions. It reads a file to stdout, the display in most cases. The main uses of cat are to quickly view the content of a file or to pipe the file to another command.
The syntax of the cat command is:
cat [options] [file]
The cat command sends the content of a file(binary, ASCII, or UNICODE) to the terminal.Concatenation is limited to ASCII text files only.
To display the content of a file, you only have to issue the cat command with the file name.
cat testfile.txt
if cat is typed by itself it will simply echo stdin to stdout, meaning everything you type will be echoed back tot he display.
There are several directory structures where cat is very useful, like /proc and /sys. These directories contain a lot of system information. Some useful examples of viewing this information are below.
cat /proc/meminfo
cat /proc/cpuinfo
To copy or append a file with cat. You would just need to redirect stdout.
cat myfile1.txt > myfile2.txt
cat myfile1.txt >> myfile2.txt
The cat command has a few useful options when viewing file content. The most common are
The cat command is a quick way of viewing the content of a file. It is useful for exploring the /proc and /sys directories.
It can also be used to copy files by redirecting stdout.
Add New Comment