Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Sep 2002 15:53:49 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: find case-insensitive challenge
Message-ID:  <200209191353.g8JDrnlA057534@lurza.secnetix.de>
In-Reply-To: <20020919013548.H83658-100000@earl-grey.cloud9.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Leftwich <Hostmaster@video2video.com> wrote:
 > Tonight I surprised myself by running `find ~/Desktop/folder/ -name "*.jpg"
 > -exec mv {} ~/Desktop/folderjpgs/ \;` successfully!  My first custom find
 > command line ever.
 > 
 > But there were two issues -- I had to escape the semicolon with a "\" --
 > does this ever cause problems for find command lines?  Second, this found
 > only *.jpg files and left behind *.JPG files so how do you make find be
 > case-insensitive? -exec ThankYouScript.sh {} \;

In general, it is a good idea to try to avoid -exec, because
it is inefficient.  -exec runs the specified command for every
single file, whilch can be terribly slow if there are a lot of
files.  Better use xargs instead, which will collect multiple
filenames and execute the command fewer times.

This also enables you to use grep to filter the file names in
a more sophisticated way than find itself can do:

find foo -type f | grep -i '\.jpg$' | xargs -J % mv % bar

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209191353.g8JDrnlA057534>