"Linux learning is not difficult" Linux Common Operations Command (1): Cat command display text file content

Source: Internet
Author: User

8.1 "Linux learning is not difficult" Linux Common Operations Command (1): Cat command display text file content

You can use the Cat command to display the contents of a text file, or to attach several file contents to another file. If no file is specified, or if the file is "-", it is read from the standard input.

Command syntax:

Cat [Options] [file]

The meanings of the options in the command are as shown in the table.

Options

option meaning

-N

numbering all lines of the output

-B

number of non-null output lines

-S

when you encounter a row that has more than two rows in a row, replace it with a blank line of one row

-E

Show $ at end of each line


Example: Displays the contents of a/etc/inittab file.

[Email protected] ~]# Cat/etc/inittab

Example: Add a line number to the file textfile1 the file and enter it into the Textfile2 file.

[[email protected] ~]# cat textfile1 a b c//view file contents textfile1 [[email protected] ~]# cat-n textfile1 > textfile2 [[E Mail protected] ~]# cat Textfile2 1 a 2 B 3 c//View the file contents of the file Textfile2, there are two columns of data, the first column is the line number of the Textfile1 file, the second column is Textfile 1 contents of the file

Example: Create a mm.txt file using the Cat command.

[[email protected] ~]# cat >mm.txt<<EOF> Hello//Enter character in Hello > Linux In this input character Linux > EOF//The input character EOF, will automatically return to the shell prompt interface [[email protected] ~ ]# Cat Mm.txt Hello Linux



This article extracts from "Linux Learning is not difficult" textbook, which is one of the most practical, theoretical and practical Linux Introductory materials. To read the entire book, visit the Linux ops (www.linuxywz.com) website .



Linux learning is not difficult "Linux Common Operations Command (1): Cat command Displays text file contents

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.