English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The cat (full English name: concatenate) command is used to concatenate files and print them to the standard output device.
All users
cat [-AbeEnstTuv] [--help] [--version] fileName
-n or --numberBy 1 Start numbering all output lines.
-b or --number-nonblankAnd -n Similar, but not numbered for blank lines.
-s or --squeeze-blankWhen encountering more than two consecutive blank lines, replace them with a single blank line.
-v or --show-nonprinting: Use ^ and M- : Symbols, except LFD and TAB.
-E or --show-ends : Display $ at the end of each line.
-T or --show-tabs: Display the TAB character as ^I.
-A, --show-all: Is equivalent to -vET.
-e:Is equivalent to-vE"option;
-t:Is equivalent to-vT"option;
Copy textfile1 Add line numbers to the document content and input textfile2 This document contains:
cat -n textfile1 > textfile2
Copy textfile1 and textfile2 Add line numbers to the document content (blank lines are not added) and then append the content to textfile3 In the document:
cat -b textfile1 textfile2 >> textfile3
Clear /etc/Content of test.txt document:
cat /dev/null > /etc/test.txt
cat can also be used to create image files. For example, to create a floppy disk image file, after placing the floppy disk, input:
cat /dev/fd0 > OUTFILE
On the contrary, if you want to write the image file to a floppy disk, input:
cat IMG_FILE > /dev/fd0
Note:
1OUTFILE refers to the output image filename.
2IMG_FILE refers to the image file.
3When writing back to device from the image file, the device capacity needs to be equivalent.
4Used to make bootable disks usually.