From owner-freebsd-questions Thu Sep 19 6:53:53 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C32D637B401 for ; Thu, 19 Sep 2002 06:53:51 -0700 (PDT) Received: from lurza.secnetix.de (lurza.secnetix.de [212.66.1.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id E696A43E4A for ; Thu, 19 Sep 2002 06:53:50 -0700 (PDT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [IPv6:::1]) by lurza.secnetix.de (8.12.5/8.12.5) with ESMTP id g8JDrnmC057535 for ; Thu, 19 Sep 2002 15:53:49 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.12.5/8.12.5/Submit) id g8JDrnlA057534; Thu, 19 Sep 2002 15:53:49 +0200 (CEST) Date: Thu, 19 Sep 2002 15:53:49 +0200 (CEST) Message-Id: <200209191353.g8JDrnlA057534@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Reply-To: freebsd-questions@FreeBSD.ORG Subject: Re: find case-insensitive challenge In-Reply-To: <20020919013548.H83658-100000@earl-grey.cloud9.net> X-Newsgroups: list.freebsd-questions User-Agent: tin/1.5.4-20000523 ("1959") (UNIX) (FreeBSD/4.6-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Leftwich 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