One Linux command per day-cat

Source: Internet
Author: User

Cat commands in Linux are commonly used to connect files or standard input and print, or to stitch together several files in standard input and print, often in conjunction with redirection symbols.

    1. Command format

      Cat [option] ... [File] ...

    2. Command function

      1. Show entire file contents at once: Cat filename

      2. Create a file from the keyboard: Cat > NewFile, can only create new files to use, cannot edit existing files

      3. Combine several files into one file: Cat file1 file2 > File3

    3. Command parameters

      -A or--show-all equivalent to-vet

      -B or--number-nonblank number of non-null output lines

      -e equivalent to-ve

      -e shows $ at the end of each line

      -N or--number numbering of all output lines

      -S or--squeeze-blank encounters more than two rows of contiguous empty rows, turning these empty lines into a blank row

      -T equivalent to-VT

      -U is ignored

-V or--show-nonprinting use ^ and M-references, except LFD and TAB


Example: 1. viewing file content Instances

[[email protected] ~]# cat ett.txt #查看ett. txt [[email protected] ~]# cat-b ett.txt #查看ett. txt content, numbering non-empty lines, starting with 1 [email Protected] ~]# cat-n ett.txt #查看ett. txt content, numbering all lines, starting with 1 [[email protected] ~]# cat-e ett.txt #查看ett. txt content, adding a $[at the end of each line when output [email protected] ~]# cat ett.txt a.txt #同时查看ett. txt and a.txt content. [email protected] ~]# Cat Install.log Install.log.syslog | More #查看大文件时通过管道符使用more可以进行分页显示.

2. Create and connect file instances

[[email protected] ~]# cat > Readme.txt hahahahjdwkjhashdlinuxoldboy# Press Ctrl+d to exit save [email protected] ~]############## #######################[[email protected] ~]# cat > Readme.txt<
[[email protected] ~]# cat a.txt b.txt c.txt >d.txt #合并a, b, c file contents, input to d.txt[[email protected] ~]# cat a.txt b.txt c.txt >> e.txt contents of #合并a, B, c files, append to E.txt


We know that ">" and ">>" are all data flow redirection operations, but > overwriting,>> during operation is an append, and the actual operation needs to generate a new file ">" and ">>" can be implemented, However, only the append can only use ">>", ">" Use caution, such as the existing configuration file using ">" will be the existing configuration empty, if there is no backup is troublesome.

One Linux command per day-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.