Cat commands-linux common commands cat usage

Source: Internet
Author: User

The cat command is used to print the connection file to the output device
Cat is the basic Text Output command for Linux and is typically used to view the contents of a file.
Grammar
Cat (Parameters) (option)
-N or--number: Numbers the number of rows for all outputs starting from 1.
-B or--number-nonblank: Similar to-n, except that blank lines are not numbered.
-S or--squeeze-blank: a blank line that is substituted for a row when it encounters a blank line that has more than two consecutive lines.
-V or--show-nonprinting: Use the ^ and m symbols, except for LFD and TAB.
-E or--show-ends: Displays $ at the end of each line.
-T or--show-tabs: Displays the TAB character as ^i.
-e: Equivalent to-ve.
-A,--show-all: equivalent to-vet.
-T: equivalent to the "-vt" option;
Cat Main Features
1. Display all contents of a file at once cat filename
2. Create a new file from disk Cat >filename (can only create new files cannot edit existing files)
3. Merge several files into one file cat?? File1?? File2? > File

Case
Cat-n file1 > File2 Add the file contents of the File1 and enter the File2 file.
Cat-b file1file2 >> file3 file1 and file2 document content with line numbers (blank lines not added) after attaching the contents to the File3 document:
If the original B.txt file is not. So:
Cat >b.txt <<eof

Eof
After entering the first line, input EOF, enter, you can generate a b.txt file. Where EOF is telling bash which symbol represents the end of the file. Of course you can also use your own custom symbols.
[email protected] tmp]$ cat >B.TXT<<ABC
1
2
3
Abc
[email protected] tmp]$ cat B.txt
1
2
3
Empty the contents of the/etc/test.txt document:
Cat/dev/null >/etc/test.txt

Cat commands-linux common commands cat usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.