Linux shell Command Cat

Source: Internet
Author: User

Cat: View the contents of a file, connect a file, create one or more files, and redirect output to a terminal or file usage: cat [options] [file]

1. $ Cat Hello.txt

displaying content in a hello.txt text file

2. $ cat-n File

-N option to display the contents and line numbers of a file

3. $ cat-b File

-b option, similar to-N, but only identifies line numbers for non-blank lines

4. $ cat-e File

The-e option, which displays the "$" character at the end of each line, is useful when you need to convert multiple lines of content into a single line.

5. $ cat

If you enter only the cat command, it simply receives the standard input and displays it in the standard output, so when you enter a line and press ENTER, the same content is displayed on the next line.

such as: $ cat

Hello world!

Hello world!

$

REDIRECT words:

$ cat >hello

Hello world!

(ctrl+d key combination exits, the input of the content Hello world! will be written to the file Hello)

$ cat Hello

Hello world!

$

There are two redirect operators: > and >>, the former is content overlay, and the latter is the last append of the most files.

6. Connect the contents of multiple files to a new file

$ cat Test test1 > Test2

$ cat Test2

The results will display the contents of test and test1.

Linux shell Command Cat

Related Article

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.