Search Source Members For Two Or More Strings
April 2, 2014 Hey, Ted
I have used option 25 of the Work with Members Using PDM (WRKMBRPDM) for years to look for character strings in source physical file members. Is there a way to search for two or more strings at once? –T. It’s not possible with that option. You might want to use option -e of Qshell’s grep utility. Let’s say you want to find all instances of invnbr and invoicenumber in source physical file SRC in library TST. Here’s the command you would need to use: $ grep -in -e 'invnbr > invoicenumber > ' /qsys.lib/tst.lib/src.file/* The first, third, and fifth lines are Qshell prompt characters (i.e., $ and >). The second, fourth, and sixth lines are the ones that you key. Notice the three switches.
Qshell responds with a listing something like this one: /qsys.lib/tst.lib/src.file/CRT.MBR:6: ( InvoiceNumber dec (5,0) not null, /qsys.lib/tst.lib/src.file/CRT.MBR:9: primary key (InvoiceNumber)); /qsys.lib/tst.lib/src.file/CRT.MBR:16: ( InvoiceNumber dec (5,0) not null, /qsys.lib/tst.lib/src.file/CRT.MBR:21: primary key (InvoiceNumber, Line)); /qsys.lib/tst.lib/src.file/PRTF.MBR:2: A INVNBR 5 0 /qsys.lib/tst.lib/src.file/INV01R.MBR:37: select Ln.InvNbr, Ln.Line, /qsys.lib/tst.lib/src.file/INV01R.MBR:44: on Ln.InvNbr = Hdr.InvNbr /qsys.lib/tst.lib/src.file/INV01R.MBR:73: PrtINVNBR = zInvoiceNbr; /qsys.lib/tst.lib/src.file/INV102.MBR:76: PrtInvNbr = ZIn(x).InvoiceNbr; Each line of output breaks down so:
To write the contents to an IFS file (e.g., matches.txt), add redirection to the end of the command. $ grep -in -e 'invnbr > invoicenumber > ' /qsys.lib/tst.lib/src.file/* >matches.txt To write the results to a report, use the Rfile utility. $ grep -in -e 'invnbr > invoicenumber > ' /qsys.lib/tst.lib/src.file/* | Rfile -wQ qsysprt –Ted RELATED STORIES Looking for Strings in the IFS Using Grep to Search Source Physical Files
|