In today's command line basics, I'm going to show you how to redirect output from the bash cli (command line interface). The output of most GNU command line tools is normally sent to the terminal (ie - standard output). There are times when you would like to have the output saved as a file. Now, you could copy the text from the terminal and paste it into a text editor and save it, but there's a better way.
The GNU tools in your typical Linux distro provide a simple way to save the command output. This is done by using the greater than symbol ( > ).
Say you would like to save a listing of all your files in your home directory and call it files.txt. You would simply enter the following at the command line prompt:
Redirecting output with > will create a new file. What if you want to append the output to the end of an existing file? Well you can do that with >>.
For example, you can append the date and time to the end of your files.txt file. The date
command will print the current time and date. Try it out in the terminal.
Now use the same command, but redirect the output to append it to the end of files.txt.
You can view your file with the cat command.
#