• 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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    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

    Two More Customer Wins for Vault400 Big Blue Talks About IBM i And PureSystems

    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

  • EvolveWare Makes Progress With RPG Code Modernization Using AI
  • Why The IBM i Market Needed Another VTL Option
  • What Price Power?
  • Cloud Revenues Saved By The GenAI Boom
  • IBM i PTF Guide, Volume 27, Number 44
  • Power Systems Grows Nicely In Q3, Looks To Grow For All 2025, Too
  • Beta Of MCP Server Opens Up IBM i For Agentic AI
  • Sundry IBM i And Power Stack Announcements For Your Consideration
  • Please Take The IBM i Marketplace Survey
  • IBM i PTF Guide, Volume 27, Number 43

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