I\'ve been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don\'t normally h
Don't mean to beat a dead horse, but there are too many answers here that use tee
, which means you have to redirect stdout
to /dev/null
unless you want to see a copy on the screen.
A simpler solution is to just use cat
like this:
sudo ls -hal /root/ | sudo bash -c "cat > /root/test.out"
Notice how the redirection is put inside quotes so that it is evaluated by a shell started by sudo
instead of the one running it.