[LBo] "find" util

Stefan Waidele Stefan at Waidele.info
Mon Nov 13 18:54:22 CET 2006


Geoff Jones schrieb:
> Hi,
> I have been playing with "find" [ seems I could spend a week on this alone ! ]
> 
>> geoff at debian:~/myfiles$ find . -name "[a-m]*" -exec mv "{}" ../dir_a_m \;
>> geoff at debian:~/myfiles$ find . -name "[!a-m]*" -exec mv "{}" ../dir_n_z  \;
>> mv: cannot move `.' to `../dir_n_z/.': Device or resource busy
> 
> 
> Does the last err message mean once all the current dir files are moved, it is 
> trying to move the current directory itself?

Yes. And since you are "in" the current directory, it cannot be moved.

> [ It has the desired effect of moving a-m files to dir_a_m and n-z files to 
> dir_n_z ]

-name "[!a-m.]*"
should exlude all files starting with a dot, which is ok if you don't 
want to move the hidden files which might be in the current directory.

> Does any-one have links to good "find" syntax  tutorial - I found the man + 
> info pages hard going.

Not exactly for find, but there are some examples on our regex-page at
http://linuxbasics.org/tutorials/advanced/realworld/regex
There you find also links to further info on the regex part of find.

The "Welcome to the realworld" section of the LBo-site uses find quite 
often in real-world commandline scenarios:
http://linuxbasics.org/tutorials/advanced/realworld/start

But I'd bet there are find-tutorials out there :)

Stefan


More information about the QnA mailing list