Re: Unix grep question

2008-02-12 Thread Steve Comstock

Paul Gilmartin wrote:

On Tue, 12 Feb 2008 09:06:57 -0700, Steve Comstock wrote:


From Shell Script Programming in z/OS UNIX
(http://www.trainersfriend.com/UNIX_and_Web_courses/u515descr.htm):



Bad URL.  Might help to delimit it with blanks:



( http://www.trainersfriend.com/UNIX_and_Web_courses/u515descr.htm ):




-exec command \;   - runs specified command; if command
 contains this string {}, the string
 is replaced by the found file

also, later...

 find . -name 'string' -exec grep -i fa {} \;



If you're doing this, I'd suggest:

find . -name 'string' -exec grep -i fa {} /dev/null \;

... to cause the filenames to appear in the output.

-- gil


Excellent suggestion, Paul. Thanks.


Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
* Our classes include
   + How things work
   + Programming examples with realistic applications
   + Starter / skeleton code
   + Complete working programs
   + Useful utilities and subroutines
   + Tips and techniques

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Paul Gilmartin
On Tue, 12 Feb 2008 09:06:57 -0700, Steve Comstock wrote:
 From Shell Script Programming in z/OS UNIX
(http://www.trainersfriend.com/UNIX_and_Web_courses/u515descr.htm):

Bad URL.  Might help to delimit it with blanks:

( http://www.trainersfriend.com/UNIX_and_Web_courses/u515descr.htm ):

-exec command \;   - runs specified command; if command
   contains this string {}, the string
   is replaced by the found file

also, later...

   find . -name 'string' -exec grep -i fa {} \;

If you're doing this, I'd suggest:

find . -name 'string' -exec grep -i fa {} /dev/null \;

... to cause the filenames to appear in the output.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Steve Comstock

Luis M Martinez wrote:

According to the link posted I'd use:

find . -exec grep www.athabasca {} \;   From your working Directory
find /my_path -exec grep www.athabasca {} \;   From whatever path


I've never used the '{}' notation ... try first without the quotes.



From Shell Script Programming in z/OS UNIX
(http://www.trainersfriend.com/UNIX_and_Web_courses/u515descr.htm):

-exec command \;   - runs specified command; if command
  contains this string {}, the string
  is replaced by the found file

also, later...

  find . -name 'string' -exec grep -i fa {} \;

or

  grep -i fa  $(find . -name 'in*')

...

generally the second is faster.




Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
* Our classes include
   + How things work
   + Programming examples with realistic applications
   + Starter / skeleton code
   + Complete working programs
   + Useful utilities and subroutines
   + Tips and techniques

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Paul Gilmartin
On Tue, 12 Feb 2008 07:38:28 -0600, Todd Burrell wrote:

I have a user that is using the GREP command in Unix.  Apparently he is

ITYM grep.

searching through an anourmous list of files, and he is exceeding the ARG_MAX
value for grep.  Is there a way on the mainframe to raise this value?  I have
looked through the manuals and I don't see any way to change this, but I
might have missed something.

find ... | xargs grep ...

Hammer and file to fit.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Darren Evans-Young
Try this:

ls -1 | xargs -i grep -l searchstring {}

Of course, replace searchstring with whatever you
are searching for. The option on ls is a one, not
the letter L. The option on grep is the letter L.

Darren

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Luis M Martinez
According to the link posted I'd use:

find . -exec grep www.athabasca {} \;   From your working Directory
find /my_path -exec grep www.athabasca {} \;   From whatever path


I've never used the '{}' notation ... try first without the quotes.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Luis M Martinez
Hello,

Could you post your command and the error message an I can help you with 
the solution

On most of the Unix distributions you have the limits on the file 
named /usr/include/limits.h. I can'nt remember if USS have it.

If you cann't defeat the limits ... then try with a small shellscript  using 
awk 
(get_line() and close()) and reading the file names from an input file 
previously 
generated with the list of files to grep.  

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Kirk Wolf
Best to use grep along with find for this kind of thing.

See:   http://www.athabascau.ca/html/depts/compserv/webunit/HOWTO/find.htm



On Feb 12, 2008 7:38 AM, Todd Burrell [EMAIL PROTECTED] wrote:
 Hello:
 I have a user that is using the GREP command in Unix.  Apparently he is
 searching through an anourmous list of files, and he is exceeding the ARG_MAX
 value for grep.  Is there a way on the mainframe to raise this value?  I have
 looked through the manuals and I don't see any way to change this, but I
 might have missed something.
 Thanks
 Todd Burrell

 --
 For IBM-MAIN subscribe / signoff / archive access instructions,
 send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
 Search the archives at http://bama.ua.edu/archives/ibm-main.html


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Unix grep question

2008-02-12 Thread Todd Burrell
Hello:
I have a user that is using the GREP command in Unix.  Apparently he is 
searching through an anourmous list of files, and he is exceeding the ARG_MAX 
value for grep.  Is there a way on the mainframe to raise this value?  I have 
looked through the manuals and I don't see any way to change this, but I 
might have missed something.  
Thanks
Todd Burrell

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: Unix grep question

2008-02-12 Thread Paul Gilmartin
On Tue, 12 Feb 2008 09:06:57 -0700, Steve Comstock wrote:

   find . -name 'string' -exec grep -i fa {} \;

or

   grep -i fa  $(find . -name 'in*')

...

generally the second is faster.

Yes, but it will likewise fail on the OP's ARG_MAX problem.  Also
will fail if any of the filenames contain metacharacters.  One
wishes for the GNU find's -print0 option coupled with their xargs's
-0 option.

-- gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html