Re: redirecting the output with sudo
On Wed, Nov 16, 2005 at 10:29:43PM -0500, kamaraju kusumanchi wrote:
> Is there a way to do this in one single command?
>
> $wajig doc > /tmp/wajig_doc.txt
> $sudo mv /tmp/wajig_doc.txt /root/wajig_doc.txt
>
> ie I want to redirect the output of a command to a file and store this
> in a directory owned by root. Is there a way to achieve the above with a
> single command?
>
> I have tried
>
> $sudo wajig doc > /root/wajig_doc.txt
this should work:
sudo bash -c 'wajig doc > /root/wajig_doc.txt'
(it passes the whole command to a subshell run as root)
Almut
Reply to: