[kwlug-disc] A little help with the find command

Chris Irwin chris at chrisirwin.ca
Wed Jul 16 17:13:57 EDT 2014


You can -o (or) and -a (and) requirements as necessary. You can also
logically group them with brackets if your logic is complex.

find /home/rbclemen/src -iname '*blah*' -a -iname '*crud*' -a -iname
'*junk*'

You definitely want to use quotes around your params. The * in your find
commands will be expanded if you have matching file patterns in your
current directory, which will cause your command to not work. Quoting is
also important in your mv command, in case file names or paths contain
spaces. Also, you likely can just -exec your command, without having to use
xargs:

find /home/rbclemen/src -iname '*blah*' -a -iname '*crud*' -a -iname
'*junk*' -exec mv -v '{}' . \;


On Wed, Jul 16, 2014 at 4:13 PM, R. Brent Clements <rbclemen at gmail.com>
wrote:

> I am searching through pretty well randomized directories for files using
> strings that I have massaged into the form *blah*crud*junk* using a
> spreadsheet.  So the command:
>
> find /home/rbclemen/src -iname *blah*crud*junk* -print0 | xargs -t -0 -I
> {} mv -v {} .
>
> does what I want it to.  It would be more useful, however, if the order of
> the words in the search string was not relevant.  it currently only finds
> instances where those words appear in that order, or as part of words that
> appear in that order.  Anyone able to suggest a way to make the matching of
> the multiple terms not order dependent?  Producing additional strings with
> the terms in a different order would be non trivial.
>
> Brent
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>


-- 
Chris Irwin
<chris at chrisirwin.ca>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20140716/d1a43eae/attachment.htm>


More information about the kwlug-disc mailing list