Linux Tip of the Day - Moving files around
Here is another way to move files around.
Sometimes you find yourself wanting to move a bunch of files into a new directory that is to be created in the current working directory.
Rather than using a temporary directory, or grep and variable substitution; use a subshell:
$ ( \ls; echo dir; mkdir dir ) | xargs mv
The trick is in using a subshell to run a number of commands _before_ the output is piped to xargs. This idiom is also useful for plenty of other applications.
Comments
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
