How to Save the Output of a Command to a File in Linux Terminal [Beginner’s Tip]

When you run a command or script in the Linux terminal it prints the output on the screen for your immediate viewing.

There will be times when you need to save the output to a file for future references. Now you can surely copy and paste in Linux terminal but there are better ways to save the output of a shell script or command in Linux command line. Let me show them to you.

You can use redirection in Linux for this purpose. With redirection operator instead of showing the output on the screen it goes to the provided file.

Use the STDOUT redirection operator gt for redirecting the output to a file like this.

If the file.txt doesn8217t exist it will be created automatically. If you use the gt redirect again with the same file the file content is replaced by the new output.

...

Read Full Post

News Link: https://itsfoss.com/save-command-output-to-file-linux/.
RSS Link: https://itsfoss.com/feed/.

Linux Chatter is a news aggregator service that curates some of the best Linux, Cloud, Technical Guides, Hardware and Security news. We display just enough content from the original post to spark your interest. If you like the topic, then click on the 'read full post' button to visit the author's website. Use Linux Chatter to find content from amazing authors!

Note: The content provided has been modified and is not displayed as intended by the author. Any trademarks, copyrights and rights remain with the source.

Disclaimer: Linux Chatter sources content from RSS feeds and personal content submissions. The views and opinions expressed in these articles are those of the authors and do not necessarily reflect those of Linux Chatter.