Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #7109

Re: Case insensitive bash search?

From Tim Watts <tw+usenet@dionic.net>
Newsgroups comp.os.linux.misc
Subject Re: Case insensitive bash search?
Date 2013-01-26 11:21 +0000
Organization A noiseless patient Spider
Message-ID <6qqct9-55l.ln1@squidward.local.dionic.net> (permalink)
References <kdudlt$48h$1@speranza.aioe.org> <2t4bt9-gls.ln1@squidward.local.dionic.net> <kdv2s6$sl7$1@speranza.aioe.org> <rghbt9-oa9.ln1@squidward.local.dionic.net> <kdv6ra$53e$1@speranza.aioe.org>

Show all headers | View raw


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."

Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 08:59 -0800
  Re: Case insensitive bash search? Robert Heller <heller@deepsoft.com> - 2013-01-25 11:44 -0600
    Re: Case insensitive bash search? gazelle@shell.xmission.com (Kenny McCormack) - 2013-01-29 13:56 +0000
      Re: Case insensitive bash search? Wayne <nospam@all.invalid> - 2013-01-29 12:41 -0500
  Re: Case insensitive bash search? unruh <unruh@invalid.ca> - 2013-01-25 17:59 +0000
    Re: Case insensitive bash search? Lew Pitcher <lpitcher@teksavvy.com> - 2013-01-25 13:13 -0500
      Re: Case insensitive bash search? Lew Pitcher <lpitcher@teksavvy.com> - 2013-01-25 13:23 -0500
    Re: Case insensitive bash search? Richard Kettlewell <rjk@greenend.org.uk> - 2013-01-25 19:48 +0000
      Re: Case insensitive bash search? ray carter <ray@zianet.com> - 2013-01-25 20:45 +0000
        Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 14:58 -0800
          Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 15:28 -0800
            Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 16:14 -0800
            Re: Case insensitive bash search? Robert Heller <heller@deepsoft.com> - 2013-01-25 19:04 -0600
            Re: Case insensitive bash search? unruh <unruh@invalid.ca> - 2013-01-26 06:51 +0000
      Re: Case insensitive bash search? unruh <unruh@invalid.ca> - 2013-01-26 06:47 +0000
        Re: Case insensitive bash search? unruh <unruh@invalid.ca> - 2013-01-26 16:36 +0000
  Re: Case insensitive bash search? Tim Watts <tw+usenet@dionic.net> - 2013-01-25 20:01 +0000
    Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 15:01 -0800
      Re: Case insensitive bash search? Tim Watts <tw+usenet@dionic.net> - 2013-01-25 23:36 +0000
        Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-25 16:09 -0800
          Re: Case insensitive bash search? Tim Watts <tw+usenet@dionic.net> - 2013-01-26 11:21 +0000
            Re: Case insensitive bash search? Jon Danniken <jonSPAMdanniken@yaSMPAhoo.com> - 2013-01-26 15:14 -0800
        Re: Case insensitive bash search? "Chris F.A. Johnson" <cfajohnson@gmail.com> - 2013-01-25 20:11 -0500

csiph-web