CategoryComputingTips > SudoCompTips
Making redirection work
sudo echo foo >bar
may not work if you don't have write permissions as your user to the current directory as only the "echo foo" bit is passed to sudo.
Instead you can do things like:
sudo sh -c 'echo foo >bar'
It spawns another shell but the redirection will work.
Another alternative is to use Adverbio from http://www.greenend.org.uk/rjk/2001/06/adverbio.html which helps avoid shell quoting issues.
sudo adverbio -o bar -- echo foo