I could have just as easily opened vim/emacs/notepad and done the same, or for that matter, written the contents to an actual file instead of redirecting the contents to /dev/null.
dangerous-commands \n
^d #eof
dangerous-commmands \n #repeat
(I'm not actually sure if you can paste ^d in general... but I expect you could?)Another handy convention is the magic "-" filename (which is not actually a file). Many tools interpret that to mean stdin/stdout. For example here is a trick to copy a tree of files:
tar cf - src | (cd dest && tar xvf -)But wrt your trick to copy a tree of files, what's wrong with `cp -r src dest`, or `scp -r src desthostname:/dest` if it's over a network? Is there some advantage this way?
cd ~/src/mysite && tar cf - . | (cd /var/www/public_html && tar xvf -)
or this (remotely): cd ~/src/mysite && tar czf - . | ssh mysite 'tar xvzf - -C /var/www/public_html'
I would probably actually use rsync for this, but there have been times the tar approach came in handy.A long time ago, in the dark ages of version control, I used to use tar for rollback-able deployments: I would create a tarball of the files in development to be deployed, and I would create a tarball of the files in production to be overwritten. Then I could just explode one tarball to deploy and the other to rollback. Not something I'd do today, but we didn't always have such nice tools. :-)