Concatenate is the name of the command used in Linux to show the contents of a file or files in the terminal. The use of cat command can also merge files together and make new ones.
Basis Syntax:
cat [filename]
Filename can be a name of the file or the full path to a file in a different location. The content of the file is shown on the terminal.
Common Options used with cat command
- -n: All output lines are numbered with the -n option and the numbers are assigned to each new line.
- -s: Repeated empty output lines are suppressed using this option.
- -E: The “$” sign, which serves as a line break indicator, is displayed at the end of each line.
- -b: Only non-blank output lines will be numbered using the -b option.
- -T: Tab characters are displayed as “^I” when the -T option is used.
Uses of cat command
- to quickly inspect the contents of a file on the terminal.
- to display a “$” sign at the end of each line, indicating the end of the line use “-E “option.
- The -n option is very helpful when you need to number all output lines.
- to number non-blank output lines, the -b option is helpful.
- to display tab characters as “^I,” the -T option is helpful.
It’s worth pointing out that the cat command can create new files by rerouting the program’s output to a new file and also concatenate files by giving multiple file names separated by spaces.
If you want to know about all the common and important command for the Linux terminal then have a look at the article linked below.