cat command is one of the most frequently used command in Linux. It is used to read the contents of the file and print on the standard output i.e. the terminal. Other uses of cat commands are to create new files, combine files and copy files.
cat [option]… [file]…
Here are some ways we can use the cat command:
- Create a new file. It can create empty file as well. It is also used to read the contents of the file.
- Read multiple files at the same time.
- Concatenate multiple files into a new file.
- Copy contents from on file to another. If the file already exists then it will overwrite the file. If the file doesn’t exist, then a new file will be created.
- Append the contents of one file to another. You can append the contents of multiple file as well.
Various parameters can be used with cat command:
- -n: number all output lines.
- -b: numbers nonempty output lines.
- -e: displays $ at the end of each line.
- -s: suppress repeated empty output lines.