[CLUE-Tech] finding, sorting and moving selected files via the command line

David Anselmi anselmi at americanisp.net
Sun May 26 16:08:01 MDT 2002


"Jed S. Baer" wrote:
> 
> find {path} {criteria} | awk '{
> print "mv " $1 " {destination path}' | sh

find [path] [criteria] -exec mv {} [destination] \;

is a shorter version.  Note that [] delimit things you fill in.  The {}
is where find will substitute in the name (path) of the matching file. 
Also, the exec command line has to end with an escaped semi-colon.

As to getting the criteria right, just run the command with the -exec
part off.  Then you can see what find will find.  When you have it
right, add the rest (command history is very useful for this).

Likewise when rm'ing things.  Type 'ls [some glob]' and when you get the
right output, pull up the line in command history and change the ls to
rm.  No guessing about what will get removed.

Dave



More information about the clue-tech mailing list