Linux Advanced Commands (a): redirect command, redirection command will display the contents of the terminal redirected to a file

Redirect command


learning target

  • The command can be used to redirect the terminal to display the contents of the file redirection

Introduction 1. Redirect command

Redirect also known as output redirection, and save the results of executing the command in the terminal to the destination file.

2. Use the redirect command

command Explanation
> If the file will overwrite the previous contents of the file exists, the file operation is equivalent to 'w' mode
>> If the file exists appended to the end of the file is written, the file operation corresponding to the 'a' model

Redirect command renderings:

[Pictures of foreign chains dumping fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-47NRt74T-1583934340134) (imgs /% E9% 87% 8D% E5% AE% 9A% E5% 90% 911.png)]

[Pictures of foreign chains dumping fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-Su6xLkKy-1583934340135) (imgs /% E9% 87% 8D% E5% AE% 9A% E5% 90% 912.png)]

Description:

As long as the terminal can display the order information can be used to redirect, for example: tree

3. Summary

  • Save the contents to a file using the redirection terminal in two ways: > and >>
  • > Represent each write only the most recent data, the original data is not retained.
  • >> represents the original data is added each time on the basis of the existing data is retained.
Published 698 original articles · won praise 929 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_35456045/article/details/104806703
Recommended