Derek, another precise and informative post thank you.

I am having problems - second realted problem in a day!

I regularly ssh into my samba server and look for documents like this

cd /usr/samba/wp  (wherein lies a number of word docs)
grep -i string1 * -r

recurses through all the (sub)directories and finds files with string1
in them.

now the file list there has got too big too, and none of the solutions
posted earlier about the similar problem work, because some of the file
names have single quotes 

(like "Bill Smith NRR's bill 20 January 2004.doc")

find . -type f |xargs grep string1
xargs: unmatched single quote

I have tried

find . -type f -exec "grep string1 {}"

hoping that the quoting might help, but al i get is:

find: missing argument to `-exec' (which makes me think I do not grok
-exec)

*sigh*



On Wed, 03 Nov 2004 14:32:59 +1300 (NZDT)
Derek Smithies <[EMAIL PROTECTED]> wrote:

> Hi,
>   
> Changing system variables (like ARG_MAX) may well work, but often has
> unknown side effects..
> 
> find . -type f -maxdepth 0 | xargs grep gsa  
> 
>  is the command you want.
> 
> Search the current directory, and report all entries of type file.
> 
> For each entry, set up one instance of grep to run.
> 
> ====================================
> 
> find . -name gr\* -maxdepth 0 | xargs grep gsa
> 
>  will search all files in the current directory whose name begins with the 
> letters gr.
> 
> ==============================
> You can also use the -exec option on find to do this, and do not need the
> xargs option.
> 
> 
> However, in my view, xargs is the more intuitively obvious method.
> 
> =================================
> 
> If you removed the maxdepth 0 option, it will traverse down the directory 
> tree searching for all matching files.
> 
> Derek.
> 
> ======================================================
> 
> On Wed, 3 Nov 2004, Matthew Gregan wrote:
> 
> > At 2004-11-03T12:59:04+1300, Nick Rout wrote:
> > > [EMAIL PROTECTED] cur $ grep gsa *
> > > -/bin/bash: /bin/grep: Argument list too long
> > > [EMAIL PROTECTED] cur $ ls|wc
> > >    4299    4299  339962
> > 
> > $ getconf ARG_MAX
> > 131072
> > 
> > 339962 > ARG_MAX.
> > 
> > > on another box grep copes well with a directory of over 5000 files,
> > > albeit with 5 character file names.
> > 
> > 25000 < ARG_MAX.
> > 
> > > so, whats the easiest way to do what i want?
> > 
> > The two Tims have anwswered this bit already.
> > 
> > > I'd also be interested to know whether this is to do with the number
> > > of arguments, or the total number of characters in the argument list?
> > 
> > It's the total number of characters.  The limit (defined as ARG_MAX)
> > differs between systems; the system I am typing this on has an ARG_MAX
> > limit of 131072 and the OpenBSD box beside me has a limit of 262144.
> > 
> > Cheers,
> > -mjg
> > 
> 
> -- 
> Derek Smithies Ph.D.                           This PC runs pine on linux for email
> IndraNet Technologies Ltd.                     If you find a virus apparently from 
> me, it has
> Email: [EMAIL PROTECTED]                    forged  the e-mail headers on someone 
> else's machine
> ph +64 3 365 6485                              Please do not notify me when 
> (apparently) receiving a
> Web: http://www.indranet-technologies.com/     windows virus from me......
> 

-- 
Nick Rout <[EMAIL PROTECTED]>

Reply via email to