In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to record terminal output to text files in Centos". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
First, save the result of the command run to a file: use > to turn the output.
Example:
$ls > ls.txt # or ls-- > ls.txt # saves the running result of the ls command to the file ls.txt
Note: > directs the output to the specified file. If the file already exists, it will be rewritten, and the original contents of the file will not be retained.
The output is attached to the back of the file, and the original contents of the file will be retained.
Second, record the information into a file while outputting it: tee command
Explain what tee does:
"read from standard input and write to standard output and files", which reads from standard input and writes it to standard output and files
Parameter:-a,-- append, "append to the given FILEs, do not overwrite", append to the given file instead of overwriting it
Example:
$ls | tee ls.txt # will display the execution result of the ls command on the terminal and output the execution result to the ls.txt file
$ls | tee-a ls.txt # retains the original contents of the ls.txt file and adds the execution result of the ls command to the end of the ls.txt file.
Third, the output of multiple commands needs to be recorded: script command
The command script is very powerful and can record all the output of the terminal to the corresponding file.
Example:
1. $script
Script. Started, file is typescript
2. $ls
…… Content omission
3. $exit
Exit
Script. Done, file is typescript
4. $cat typescript # will display the green part on it again:
Description:
1. We didn't specify a file name when we started script, which is automatically recorded in a file called typescript under the current directory. You can also specify a file name with the-a parameter
Example:
$script. -a the output of the example.txt # terminal is recorded in the example.txt file
2. When you exit script, use exit. In fact, script starts a shell.
This is the end of the content of "how to record terminal output to a text file in Centos". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.