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.
News Link: https://itsfoss.com/save-command-output-to-file-linux/.
RSS Link: https://itsfoss.com/feed/.