Shell command (a shell command school day) Day cat command Example: connecting the display contents of the file

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/WilliamsWayne/article/details/91046593

Family problems, pause for a few days to update.
The cat command is one of the commonly used commands Linux system, the cat command allows us to view the contents of a file, connection files, create one or more files and redirect the output to a terminal or a file.
cat syntax of the command is as follows:

$ cat  [OPTION]  [FILE]...

View file using the cat command
Here Insert Picture Description
to view the contents of multiple files:
Here Insert Picture Description

  • Use the -n option to display the contents of the file line number
    Here Insert Picture Description
  • -B option and the -n option is similar, but only identifies the line number is not blank
    Here Insert Picture Description
  • Use the -e option, the "$" character at the end of each line. This option when you need to convert multiple lines in a row is very useful. ps: But stupid that it is possible to connect the syntax and PHP, not easy to distinguish oh.
    Here Insert Picture Description
    When you enter the catcommand, without any parameters, he only receives the contents of standard input and standard output display. So after you enter a single line and press Enter to display the same content in the next row. You can also redirect standard output to a new file, like this:
$  cat  >test

Then we will wait for user input, enter the content you want, press Ctrl + Dthe key combination to exit. The contents of the input file will be written in the test.
Here Insert Picture Description

  • Use cat redirection and use, a plurality of content files may be connected to a new file, as follows:
    Here Insert Picture Description

note

"Linux下还有一个"tac"命令,从命令的名字来看你可能已经想到了他的用户,没错"tac"命令与"cat"命令是相反的,它将以倒序的形式(先显示文件的最后一行)显示文件的内容。"

Guess you like

Origin blog.csdn.net/WilliamsWayne/article/details/91046593