Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm looking for a unix command that is the opposite of cat (but not tac).

I want to do

$ SOMECOMMAND /tmp/file
I type some content
for the file here
^D
$ cat /tmp/file
I type some content
for the file here
$

So, I actually type in 'I type some content...' after running the command, and it is written to the file. And before you suggest it, yes, I am very aware of editors -- just looking for something shorthand.

share|improve this question
up vote 7 down vote accepted

The opposite of cat is cat.

$ cat > /tmp/file
I type some content
for the file here
^D
$ cat /tmp/file
I type some content
for the file here
$
share|improve this answer
    
HA! I Love it. Will accept as soon as the 15 min are up. – John Hinnegan Jun 14 '11 at 16:14
    
@Ignacio Vazquez-Abrams's answer is also an extremely useful method that I use frequently for adding multiple host file entries in one fail swoop: # cat >> /etc/hosts and then enter numerous IP/hosts on separate lines, and finally Ctrl-C when finished. – rubynorails Sep 27 '15 at 3:31

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.