• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • 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.

    1. -i means the search is not case-sensitive
    2. -n means that the relative record number (not the value of the SRCSEQ field) is to be included in the output
    3. -e means that two or more search strings follow, separated from one another by a newline character (i.e., the Enter key)

    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:

    • The name, in IFS format, of the member in which a string was found
    • The relative record number of the line within the member
    • The contents of the line

    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

    Getting Acquainted with Grep

    Using Grep to Search Source Physical Files



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    [Webinar] Trends for 2026: ARCAD Software’s strategic vision

    Between the acceleration of artificial intelligence, constant pressure to modernize existing systems, and ever-increasing security requirements, 2026 is shaping up to be a decisive year for legacy platforms.

    At the start of this new year, this webinar offers strategic insight into the future of these critical environments, which are at the heart of information systems.

    Join Philippe Magne, CEO of ARCAD Software, as he shares his analysis of the major trends and structural issues facing organizations:

    • DevSecOps: What are the current trends in DevOps transformation?
    • Generative artificial intelligence: What are the concrete use cases and measurable benefits for application development and maintenance?
    • Critical application security: How to respond to growing and sophisticated threats?
    • Cloud and hybridization: How do legacy applications fit into current cloud strategies?

    Save your seat for March 24 at 11 AM EDT!

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    BCD:  IBM i Webinar April 10: How Automating Spool File Distribution Reduces Costs
    LANSA:  Webinar: Preserving your IBM i investment. April 10, 12 pm CT/1 pm ET
    Maxava:  Live Webinar: 11 Steps to Comprehensive DR Planning for IBM i. April 3

    More IT Jungle Resources:

    System i PTF Guide: Weekly PTF Updates
    IBM i Events Calendar: National Conferences, Local Events, and Webinars
    Breaking News: News Hot Off The Press
    TPM @ EnterpriseTech: High Performance Computing Industry News From ITJ EIC Timothy Prickett Morgan

    Embedded SQL Exception/Error Handling Admin Alert: Elements Of An IBM i Incident Management Plan, Part 1

    Leave a Reply Cancel reply

Volume 14, Number 8 -- April 2, 2014
THIS ISSUE SPONSORED BY:

CCSS
WorksRight Software
Valence Framework for IBM i

Table of Contents

  • Embedded SQL Exception/Error Handling
  • Search Source Members For Two Or More Strings
  • Admin Alert: Elements Of An IBM i Incident Management Plan, Part 1

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • No Joke: Big Memory And Flash Price Hikes Coming April 1
  • Strategic Topics To Think About For 2026, Part 2
  • Guru: IBM i Job Log Detective Brings Structure To Job Log Analysis In VS Code
  • IBM Launches Hybrid Cloud Backup Product With Cobalt Iron
  • IBM i PTF Guide, Volume 28, Number 10
  • Why You Need To Think About Offsite Data Protection
  • IBM Gets Bob 1.0 Off The Ground
  • You Store The Crown Jewels In A Safe, Not In A Bucket
  • More Power Systems Withdrawals, And Some From Red Hat, Too
  • Price Increases Are Here, Or Pending, And For Sure For Memory

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle