Tag Archives: Command Output

Raspberry Pi with Linux LESSON 8: Sending Linux Command Output to a File

This lesson shows that we can redirect the output of our Linux commands to a file instead of the terminal window.

If we have a command like:

$ ls

The output is the list of files and folders in the current directory. If we instead want to send the output to a file we could use the followingg:

$ ls >out_file.txt

The list of files and folders is directed to a new file called out_file.txt.  Note that all the same rules for paths still applies.

If we issued the command again, the old contents of the file would be overwritten. If we wanted to append the results to the end of the file instead of overwriting, we could do the following:

$ ls>>out_file.txt

When we use >> instead of >, the results will be appended to the end of the file.