Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just want to create a file with the outputted text from a command, rather then copying and pasting & making a new file by hand.

I'm on a unix machine - how do I do this?

share|improve this question

1 Answer 1

Redirecting. At the end of any command, type > filename.txt. Replace filename.txt with the file name you want to use. You can even output to different devices (dangerous) or directories (ls > /home/user/ls.txt for example)

As @Josh pointed out as well:

If you need to see the output too you can use the tee command to output to stdout as well as a file. ls | tee file.txt

share|improve this answer
2  
If you need to see the output too you can use the tee command to output to stdout as well as a file. ls | tee file.txt –  Josh Jan 4 '13 at 19:19
2  
Plus to append an existing file, use >>. –  Xyon Jan 4 '13 at 21:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.