• 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
    FalconStor

    Simplify Secure Offsite Data Protection for IBM Power with FalconStor Habanero™

    IBM i teams are under growing pressure to ensure data is protected, recoverable, and compliant—without adding complexity or disrupting stable environments.

    FalconStor Habanero™ provides secure, fully managed offsite data protection purpose-built for IBM Power. It integrates directly with existing IBM i backup tools and processes, enabling reliable offsite copies without new infrastructure, workflow changes, or added operational overhead.

    By delivering and managing the service end-to-end, FalconStor helps organizations strengthen cyber resilience, improve disaster recovery readiness, and meet compliance requirements with confidence. Offsite copies are securely maintained and available when needed, supporting recovery, audits, and business continuity.

    FalconStor Habanero offers a straightforward way to modernize offsite data protection for IBM i: focused on simplicity, reliability, and resilience.

    Learn More

    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

  • What IBM i Ideas Are Cooking In IBM’s Ideas Portal?
  • Early Bob Excels In Medhost IBM i Tryout
  • Counting The Cost Of AI Inference – And Projecting It Far Out
  • IBM i PTF Guide, Volume 28, Number 13
  • The Next Generation Of IBM i Talent in GenAI Action
  • IBM Taps Nvidia GPUs For AI-Turbocharged Data Mart
  • Izzi Partners With Capricorn For IBM i Services And Bluehouse For Software Peddling
  • IBM i PTF Guide, Volume 28, Number 12
  • What Is Your Plan For Offsite Data Protection?
  • What Is Threatening IBM i Security Now

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