Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a file from shell input. That is, I want to run some command, then type the desired contents of my file, then press Ctrl-D and have it create my file with the contents I typed in.

What would be the command for that?

share|improve this question
Is this homework? – Zypher Oct 12 '11 at 0:27
No! I'm stuck for an hour at work because of this! But I'm happy to know it's easy enough to be considered homework! – Ram Rachum Oct 12 '11 at 0:28
up vote 3 down vote accepted

You use the cat command to concatenate STDIN to the file like so: cat >> out.txt (or to blow away the already existing file, don't append cat > out.txt) then type when done press ctl+d to terminate when you are done.

share|improve this answer

Your Answer


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.