Here’s something interesting I just learned about. You can echo a command to see it’s syntaxis before running it in the command line, and then, pipe it to the shell, like this:
echo ls -ltra | awk '/.html~/' | xargs rm
(examine it carefully) and call it again adding ” bash“
echo ls -ltra | awk '/.html~/'| xargs rm | bash
Another recent use I gave to it is in this command:
svn status | grep ^M | awk '{print "scp ",$2," me@xxx:/home/myTemp/"}' | tr -d '\n' | bash
Which: 1) pulls the status from the svn, 2)filters the modified files, 3) prints the scp command with the name of the file and the destination, 4) makes that a sequence in one line (by removing the newlines “\n”), and finally pipes all to bash to execute all the commands and get the modified files moved elsewhere.
find . -type f -mtime -22 | awk '/gif/' | cut -c 3- | awk '{print "scp ",$0, " me@xxx:/home/ignacio/myTemp"}' | bash -i
This last example doesn’t need the (\n) newlines removed to run thanks to the “-i” option after bash
Ain’t it sweet?