Possible Duplicate:
How do I use sudo to redirect output to a location I don’t have permission to write to?
Let's say I want to change a file "foo" that lives in /home, applying some regular expression to it (via sed), and put the result in a file called /home/foo2.
I don't have read/write access neither to /home or to foo, so then I use sudo. However, I still get a permission denied
sudo sed "s/bar/baz/" <foo >foo2
bash: foo2: Permission denied
Any ideas? Thanks