Tuesday, November 29, 2011

Prepending text to a file

no mo' temp files

echo lol > rofl.txt
echo wut | cat - rofl.txt | tee rofl.txt > /dev/null

this makes cat concatenate firstly the stdin, which in this case is the piped output from echo, and then the file you prepend it to then redirects that stdout to tee which outputs it to the original file.


No comments:

Post a Comment