× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Peter

Be careful using sources other than the QShell docs for the utilities in QShell - there are differences that can bite you.

I don't know that grep is one of these, but it could be.

Regards
Vern

On 1/22/2012 3:08 PM, Peter Dow wrote:
Hi Guy,

From http://ss64.com/bash/grep.html

"Normally, exit status is 0 if matches were found, and 1 if no matches
were found (the `-v' option inverts the sense of the exit status).Exit
status is 2 if there were syntax errors in the pattern, inaccessible
input files, or other system errors."

The syntax being used in this case is

grep search-string files-to-search

Knowing that, and that Unix considers everything a file, including
directories, the command I gave told it to search only the file named
"Output" which happens to be a file with content that happens to be
directory entries. So instead of searching the content of the files in
the Output folder, it searched the directory entries, and didn't find
anything.

To make it search the content of the files in the Output folder, we need
to specify the names of those files, and that specification can be
generic. Try this:

QSH CMD('grep 110000890 /M3BE/env/PRD/Output/*')

I'm not sure why you didn't see anything. When I ran it, I got the
following, because I do not have any of those folders:

grep: 001-2113 Error found getting information for object
/M3BE/env/PRD/Outpu
t/*. No such path or directory.
Press ENTER to end terminal session.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
pdow@xxxxxxxxxxxxxxx<mailto:pdow@xxxxxxxxxxxxxxx> /

On 1/22/2012 10:47 AM, Guy Geboers wrote:
Hi Peter,

when I execute the command from an OS400 line, I only get the message
"Command ended normally with exit status 1", nothing else

Guy





From: Peter Dow<petercdow@xxxxxxxxx>
To: midrange-l@xxxxxxxxxxxx
Date: 18/01/2012 23:18
Subject: Re: Search in content of a IFS file
Sent by: midrange-l-bounces+guy.geboers=sibelco.com@xxxxxxxxxxxx



Or from an OS400 command line:

QSH CMD('grep 110000890 /M3BE/env/PRD/Output')


On 1/18/2012 6:23 AM, Michael Ryan wrote:
That example showed looking for the string 'table' in all the .php
files in directory /home/michael. the output of the command shows the
name of the file '/home/michael/dspcust.php:' and the line containing
the search string '// Put the results in an HTML table'. There are
multiple results.

You would do this:

grep 110000890<files in which to search>

Files in the IFS may or may not have extensions, just like Windows or
*NIX files.

On Wed, Jan 18, 2012 at 9:19 AM, Guy Geboers<Guy.Geboers@xxxxxxxxxxx>
wrote:
Hi,

When I use this statement nothing happens.
I even wonder if files in the IFS of an iSeries have extensions (?)



And can you please give me an example on how to search for a specific
string in the content of the file (so not in the filename itself) ?

Thanks a lot.
Guy






From: Michael Ryan<michaelrtr@xxxxxxxxx>
To: Midrange Systems Technical Discussion<midrange-l@xxxxxxxxxxxx>
Date: 18/01/2012 15:04
Subject: Re: Search in content of a IFS file
Sent by: midrange-l-bounces@xxxxxxxxxxxx



Use grep in QSH.

grep: 001-3010 usage: grep [-E | -F] [-c | -l | -q] [-ihnsvwxy] [-e
pattern_list] [-f pattern_file] [pattern] [file ...]

Like...

grep table /home/michael/*.php
/home/michael/dspcust.php:<table width="75%" border="1" cellspacing="1"
cellp
adding="1" bgcolor="#eeeeee">
/home/michael/dspcust.php:print("<b>The result of the ADDRFILE table
query
is
:</b>\n");
/home/michael/dspcust.php:// Put the results in an HTML table
/home/michael/dspcust.php:</table>
/home/michael/dspsum.php:<table width="75%" border="1" cellspacing="1"
cellpa
dding="1" bgcolor="#eeeeee">
/home/michael/dspsum.php:print("<b>The result of the ADDRFILE table
query
is:
</b>\n");
/home/michael/dspsum.php:// Put the results in an HTML table
/home/michael/dspsum.php:</table>
$

You can redirect the output to a file if you want...

grep table /home/michael/*.php> /home/michael/myfile.txt
On Wed, Jan 18, 2012 at 5:02 AM, Guy Geboers<Guy.Geboers@xxxxxxxxxxx>
wrote:
Hi,

In an IFS directory e.g. /M3BE/env/PRD/Output there are thousands of
files.

I need a list of all files which have the string "110000890" in their
content

Who can help me ?


thanks

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.