8.1 "Linux learning is not difficult" Linux Common Operations Command (1): Cat command display text file content
You can use the Cat command to display the contents of a text file, or to attach several file contents to another file. If no file is specified, or if the file is "-", it is read from the standard input.
Command syntax:
Cat [Options] [file]
The meanings of the options in the command are as shown in the table.
Options |
option meaning |
-N |
numbering all lines of the output |
-B |
number of non-null output lines |
-S |
when you encounter a row that has more than two rows in a row, replace it with a blank line of one row |
-E |
Show $ at end of each line |
Example: Displays the contents of a/etc/inittab file.
[Email protected] ~]# Cat/etc/inittab
Example: Add a line number to the file textfile1 the file and enter it into the Textfile2 file.
[[email protected] ~]# cat textfile1 a b c//view file contents textfile1 [[email protected] ~]# cat-n textfile1 > textfile2 [[E Mail protected] ~]# cat Textfile2 1 a 2 B 3 c//View the file contents of the file Textfile2, there are two columns of data, the first column is the line number of the Textfile1 file, the second column is Textfile 1 contents of the file
Example: Create a mm.txt file using the Cat command.
[[email protected] ~]# cat >mm.txt<<EOF> Hello//Enter character in Hello > Linux In this input character Linux > EOF//The input character EOF, will automatically return to the shell prompt interface [[email protected] ~ ]# Cat Mm.txt Hello Linux
This article extracts from "Linux Learning is not difficult" textbook, which is one of the most practical, theoretical and practical Linux Introductory materials. To read the entire book, visit the Linux ops (www.linuxywz.com) website .
Linux learning is not difficult "Linux Common Operations Command (1): Cat command Displays text file contents