Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Tim Watts Newsgroups: comp.os.linux.misc Subject: Re: Case insensitive bash search? Date: Sat, 26 Jan 2013 11:21:10 +0000 Organization: A noiseless patient Spider Lines: 59 Message-ID: <6qqct9-55l.ln1@squidward.local.dionic.net> References: <2t4bt9-gls.ln1@squidward.local.dionic.net> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Info: mx04.eternal-september.org; posting-host="ea8225101a828ce9b4323b1250493908"; logging-data="25305"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vSts5LRbkosaNp+OVjvbhGhmeij3U+I8=" User-Agent: KNode/4.8.5 Cancel-Lock: sha1:IGMuE0ZSrvBuk87ZdWMf4FY5fJo= Xref: csiph.com comp.os.linux.misc:7109 On Saturday 26 January 2013 00:09 Jon Danniken wrote in comp.os.linux.misc: > On 01/25/2013 03:36 PM, Tim Watts wrote: >> On Friday 25 January 2013 23:01 Jon Danniken wrote in comp.os.linux.misc: >> >>> Thanks Tim. My reason for trying to do this in the shell (as opposed to >>> in a file manager) is because I have some folders with a lot of files in >>> them (thousands to tens of thousands), and my file manager (Dolphin - >>> KDE) often has problems at times with folders that big. >>> >>> I find that using the shell is a *lot* quicker than the file manager, >>> and very noticeably so when interacting with one of these >>> "high-capacity" folders. >> >> I really meant "are you obsessed with not exec-ing other command >> binaries"? That could be a valid concern on a crappy little embedded >> system, but not usually a problem on a normal system - unless you are >> trying to aim for 100% portability across loads of unices - where you >> cannot assume GNU extensions etc. > > Okay, I gotcha. I'm not at that level (yet), just a home PC user for > the time being. > > Jon In that case, "find" and/or "ls -1" plus "grep" and the putput piped through "xargs" (which runs a command with all the input lines as arguments - or can run the command once per input line) can do an awful lot. I always put "echo" after "xargs" the first time just to make sure the commands look right, before running them. eg copy all files in /etc/ (non recursively) that have the second letter "A" case-insensitive to /tmp/etc mkdir /tmp/etc find /etc/ -maxdepth 1 -iname \?A\* | xargs \ --replace=FILE echo cp -v FILE /tmp/etc/ and to actually do it, remove the echo: find /etc/ -maxdepth 1 -iname \?A\* | xargs \ --replace=FILE cp -v FILE /tmp/etc/ (The multiple lines are only for the benefit of the newsreader wrapping) The above will find directories too and cp will ignore them. As an excercise, how could you modify the command to skip directories? -- Tim Watts Personal Blog: http://www.dionic.net/tim/ "History will be kind to me for I intend to write it."