Deep usage of Linux cat

Source: Internet
Author: User

command based on CENTOS6 series, translated based on the meaning of the official text.

Cat

cat-concatenatefiles and print on the standard output Connection file and print standard output

Cat [OPTION] ... [FILE] ...

DESCRIPTION Description

Concatenate FILE (s), or standard input,to standard output.

-A,--show-all

Equivalent To-vet

-B,--number-nonblank

Number nonempty output lines

-e equivalent To-ve

-E,--show-ends

Display $ at end of each line

-N,--number

Number all output lines

-S,--squeeze-blank

Suppress repeated empty outputlines

-T equivalent TO-VT

-T,--show-tabs

Display TAB characters as ^i

-U (ignored)

-V,--show-nonprinting

Use ^ and m-notation, except FORLFD and TAB

-A Show All and take $ the symbol shows the end, equivalent to -vet , and the utility degree is low.

- b displays all non-empty line numbers. That is, if it is a blank line, the line number is not displayed

- N Displays line numbers for all lines, including blank lines, etc., commonly used

- S compressed blank lines, understood to encounter more than three lines of empty lines, only one row, chicken ribs parameter

Cat of the concatenate Usage:

To create or direct a file for the input content, format:

  1. cat>>file<< xxx content xxx End

  2. Of course, you can cat> or >>file directly.

  3. Merging cat file1 file2 > File3

Cases:

[Email protected]]# cat >>1.TXT<<ABC

>1234567

>abc

[[Email protected]]# cat>2.txt

Abcdefg

^c

[[Email protected]]# cat 1.txt 2.txt

1234567

Abcdefg

[[Email protected]]# cat 1.txt 2.txt > 3.txt

[[Email protected]]# cat 3.txt

1234567

Abcdefg

the above uses the 2 different ways of creating files and merging the content together.

Print standard output :

Cat+option+file will be Linux all know, don't introduce

Summary: Cat is described in official info, and his usage is to connect and output file contents. It's just that very few people use it in the connection section. Most people only know cat print standard output. When you want to write a simple script, you can write it directly with Cat. Equivalent to an enhanced echo. Practical work is very practical.


This article is from the "Mud" blog, be sure to keep this source http://niba666.blog.51cto.com/9238216/1873555

Deep usage of Linux cat

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.