How to use the cat command under Linux?

  
                

If you want to display the contents of multiple files at the same time in Linux system, you need to use the cat command. What are the uses of the cat command? Let's take a look at the usage of the cat command under Linux.

is connected to the use of the cat command or the standard input file and print. This command is often used to display the contents of a file, or to connect several files for display, or to read and display content from standard input, which is often used in conjunction with redirection symbols.

1. Command format:

cat [options] [files]. . .

2. Command function:

cat has three main functions:

1. Display the entire file at a time: cat filename

2. Create a file from the keyboard: cat 》 filename can only be created New files, you cannot edit existing files.

3. Combine several files into one file: cat file1 file2 》 file

3. Command parameters:

-A, --show-all is equivalent to -vET

-b, --number-nonblank is numbered for non-empty output lines

-e Equivalent to -vE

-E, --show-ends displays $

-n, --number for all lines of the output, starting with 1 for all lines Number of lines outputted

-s, --squeeze-blank There are two consecutive lines of blank lines, which are replaced by blank lines of one line

-t is equivalent to -vT< Br>

-T, --show-tabs Display tab characters as ^I

-u (ignored)

-v, --show-nonprinting Use ^ and M-reference, except for LFD and TAB

4. Example:

Instance 1: Add the line number of the log2012.log file to the log2013.log file.

Command:

cat -n log2012.log Log2013.log

Output:

[root@localhost test]# cat log2012.log

2012-01

2012-02

======[root@localhost test]# cat log2013.log

2013-01

2013-02

2013-03

======[root@localhost test]# cat -n log2012.log log2013.log

1 2012-01

2 2012-02

3

4

5 ======

6 2013-01

7 2013-02

8

9

10 2013-03

11 ======[root@localhost test]#

Description:
Previous12 Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved