cat command
LINUX-Frequently used commands
cat command Display the contents of a file |
Syntax |
cat [Option] file-name |
The cat command will output the contents of the file specified as an argument to the standard output. If multiple files are specified as arguments, the contents of the specified files will be concatenated and displayed. |
Frequently used options |
-v Display control codes and other hidden codes -e In addition to the functions of the ”-v” option, add $ to the end of the line and display it -t In addition to the ”-v” option feature, display the Tab code as ^I -s Replace multiple consecutive blank lines with a single blank line |
If the contents of temp1.txt are as follows
Example: Display the contents of a file. |
$ cat temp1.txt A. abc B. def C. ghiD. |
Example: Display with $ at the end of the line |
$ cat -e temp1.txt ← Run it with the option "-e". A. abc$ B. def$ C. ghi$ $ $ $ D.$ |
Example: Display with TAB code |
$ cat -t temp1.txt ← Run it with the option "-t". A. ^|^|^|abc B. def.. C. ^|^| ghi---D. ↑The area where the tab is entered is shown as "^|". |
Example: Replace multiple consecutive blank lines with a single blank line |
$ cat -s temp1.txt ← Run it with the option "-s". A. abc B. def C. ghi ← A blank line becomes one line. D. |