Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Run all parts of a pipe as root' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run all parts of a pipe as root
Authored by: kiwi23 on Feb 13, '04 06:16:54PM

If you want to run the whole pipe as root, not only the part leading up to the | (pipe) symbol, then you need to do

sudo /bin/bash -c '<your commands here>'

for the original command line it would read

sudo /bin/bash -c 'find /Volumes/ -name "Trash Can #*" -print0 | xargs -0 rm -Rf'

This is because the shell will split the command line at the | so that the sudo will only see the first part. The commands following the | will be run under your account, not under sudo's control. The solution presented runs a whole shell as root. This shell then runs both commands of the pipe as root.



[ Reply to This | # ]