How to redirect file write from home folder to specific folder in UNIX

redirectionterminalunix

I did a search and didn't find what I was looking for. I finally found a beginners UNIX book that I like. I am going through some examples and I notice output is generated in the home folder. I am using OS X. I keep all my code on my desktop in a folder called code for all my programming assignments and practice. C,C++…etc.

So my question is, how do I do a file redirect from the terminal to create a file in a specific folder? If I type:

cal 2011 > cal2011

it creates a file called cal2011 to my home folder. How do I write at the terminal without changing directories (the initial command prompt) to save it to:

desktop/code/unix

Thank you for the help. I am still new at this…

Best Answer

Assuming you are in your homedir, the relative path works.

cal 2011 > desktop/code/unix/cal2011

If you aren't, you can use the ~ to denote your homedir

cal 2011 > ~/desktop/code/unix/cal2011
Related Question