One day a shell command Linux file content Operation series-cat command detailed _linux Shell

Source: Internet
Author: User

Note: After the awk command, there are not too many complex commands, which are basic commands.

Description

Cat, which is the abbreviation of the word concatenate, outputs the contents of the file to stdout. When the redirection operator (> or
When used in conjunction with >>, it is commonly used to connect multiple files.

Usage:

1. $cat file1 file2 File3
2. Not only can read the content from the file and stitching, but also from the standard input stream to read

For example: $echo ' some content ' | Cat-file.txt

Explanation: Here's-represents the ' some content ' temporary file, which is the input stream

Instance:

1. $cat Cat.txt

Printed all the contents of the Cat.txt

2. $cat Cat.txt | Less

View Cat.txt, add less a page after the screen, specifically after the Less,more command introduced

3. $cat-N Cat.txt

Callout line number before each line, including blank lines

4. $cat-B cat.txt

Callout line number before blank line

Interpreting--help

Usage: cat [options] ... [File] ...
Outputs a [file] or a standard input combination to the standard output.

-A,--show-all equals-vet
-B,--number-nonblank for non-null output line numbering
-E equals-ve
-E,--show-ends displays "$" at the end of each line
-N,--number all line numbers for the output
-S,--squeeze-blank does not output multiple lines of blank lines
-T and-VT equivalence
-T,--show-tabs displays the ^i character as a
-U (ignored)
-V,--show-nonprinting use ^ and M references, except LFD and TAB
--HELP displays this help information and exits
--version display version information and exit

If no file is specified, or if the file is "-", read from the standard input.

Example:
The cat f-g first outputs the contents of F, then outputs the contents of the standard input, and finally outputs the contents of G.
Cat copies the standard input to the standard output.

Interpretation:

1. Cat–s file.txt

If there is a file in this format:

Line1

#空行
Line2 File2

To use this command

Cat more with the other command, its own not too complex content, if bored, try Cat–a cat.txt, there will be unforgettable memories.

Related commands:

Cat's in-laws are usually sed,tr this order.

Such as:

$cat file|sed ' s/old/new/g '

Displays the file and converts the old to new without modifying the original file

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.