The cat command is used to concatenate files or standard input and print them. This command is often used to display the contents of a file, to concatenate several files, or to read the contents from standard input and display them. It is often used in conjunction with the redirection symbol.
The command format
Cat [options] [file]...
Functions of commands
- Read and display the entire file
cat filename
- Reads input from the keyboard into a file
cat > 1.txt
- Combine multiple files into a single file
cat 1.txt 2.txt > 3.txt
The command parameter
- -a, –show-all is equivalent to -vet
- -b, –number-nonblank Specifies the number of the non-blank output line
- -e is the same thing as -ve
- -e, –show-ends displays $at the end of each line
- -n, –number Specifies the number of all output lines, starting from 1
- -s, –squeeze-blank if there are more than two consecutive blank lines, it is replaced with one blank line
- -t is equivalent to vT
- -t, –show-tabs displays the TAB character as ^I
- -u (ignored)
- -v, –show-nonprinting uses ^ and M- references, except for LFD and TAB
will1.txt
Add the line number to the2.txt
>cat 1.txt rumenz.com rumenz 123 345 9999 3333 > cat-n 1.txt > 2. TXT >cat 2.txt 1 Rumenz.com 2 rumenz 5 6 123 7 345 8 9 10 9999 11 12 3333Copy the code
will1.txt
Enter the content (blank lines without line numbers) to2.txt
> cat-b 1. TXT > 2. TXT > cat 2. TXT 1 Entry small station 2 rumenz.com 3 rumenz 4 123 5 345 6 9999 7 3333Copy the code
Use here Doc to generate the file
TXT <<EOF > Rumenz > rumenz.com > > > 'date' > EOF > cat 3. TXT Rumenz rumenz.com Thu Feb 4 23:40:09 CST 2021Copy the code
Display the contents of multiple files simultaneously
> cat 1.txt 2.txt
Copy the code
Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station