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.

5 thoughts on “Raspberry Pi with Linux LESSON 8: Sending Linux Command Output to a File”

  1. I have followed these lessons from the start, as a new commer to the pi and lynux. I am hooked! I have really enjoyed the lessons. The repetitiveness in some between others has been very pleasing; it has helped rienforce the concepts. Thank you Paul!

  2. I love dogs too and enjoy listening to the stories as I learn the Linux, even though some are very sad. I also have a string of sports cars which must go with the boys love toys and computers and tech kinda thing.
    I love the tutorials and am learning Linux while I wait for some of the sensors to be delivered. my cheap Chinese colour sensor does not give much rgb number difference but it was only $2. Will use your expertise and lovely teaching style in my Physics lessons. All of us following these lessons are very gratefull for your time and effort.
    Kind regards,
    Mr Hughes
    physics teacher, UK

    1. Thanks for the comments, David. I am glad you find the lessons useful.

      I have put them up here free for anyone to use . . . I wish more high schools would use them. A teacher would not even need to know the material. Turn the students loose on the videos . . . I guarantee most students would pick it up, and the few that struggle could get help from the rest. Our high schools generate technologically illiterate graduates these days, especially in the US.

  3. Paul, you are delivering a wonderful set of lessons. I especially like the idiosyncrasies you inject to keep the lessons down to earth. I have just started learning Raspberry Pi coding and this site is just right for me. Keep up the excellent work!

Comments are closed.