Seiden Group
Modern Development & Open Source for IBM i
  • Link to LinkedIn
  • Link to Mail
  • Home
  • Seiden PHP+
    • Seiden PHP+
    • Install & Learn
    • SmartSupport
    • PHP Migrations & Upgrades
    • Success Stories
    • Free PHP Assessment
    • Documentation
    • What’s New (Changelog)
  • IBM i Services
    • Development
    • Training & Mentoring
    • Open Source Setup & Upgrades
    • SSL/TLS Install & Learn
    • Performance
  • Support
    • Open Source & PHP
    • VS Code for i
    • Developer Support
    • Support Success Stories
  • VS Code for i
    • Support
    • Training
    • Code for i Resource Guide
    • Getting Started Videos
    • Code for IBM i Fridays
  • Free Stuff
    • IBM i Strategy & Tips
    • PHP Upgrade Assessment
    • CNX Valence Assessment
    • VS Code for IBM i Resources
    • Code for IBM i Fridays
    • QCachegrind Download
    • PHP Toolkit for IBM i Resources
    • Qshell on i Library
  • Blog
  • About
    • About Our Team
    • About Alan Seiden
    • Speakers & Sessions
    • In the News
  • Contact
  • 201.447.2437
  • Search
  • Menu Menu

Seiden Group Blog

Physical File GREP (PFGREP): Fast IBM i Source Code Search

March 25, 2025/5 Comments/in Open Source /by Alan Seiden

pfgrep: Fast search for IBM i PFsOur 2023 article on searching source physical file members using the QShell grep command showed grep’s potential. In practice, while we found QShell grep to be flexible, we also experienced slow performance and occasional errors.

Now, our own Calvin Buckley has built an improved grep command called pfgrep to search traditional IBM i source physical file members. Quick and reliable, pfgrep is also free and open source.

Installation

Detailed installation instructions are found on the pfgrep Github page, but here are the basic three installation methods:

  • Download the .rpm file from the Github site, then install via yum
  • Seiden Group customers with access to our repositories can install directly from our repos using yum
  • Git clone from Github to build from source

Using pfgrep

Example: To find any mention of php (or PHP, or pHP) in physical files in the ALAN library, I could launch a PASE shell (SSH Bash, QShell, CALL QP2TERM) and run this case-insensitive, recursive search:

pfgrep -i -r php /QSYS.LIB/ALAN.LIB/

On my IBM i system, the results include PHP references in CL, RPG, command source, and more, that I wouldn’t have found without such a powerful search tool.

Partial output:

1
2
3
4
5
/QSYS.LIB/ALAN.LIB/QCLSRC.FILE/CALLPHPCMD.MBR: CHGVAR VAR(&CMD) VALUE('/QOpenSys/pkgs/bin/php
/QSYS.LIB/ALAN.LIB/QCLSRC.FILE/PASE2MON.MBR: CALL PGM(QP2SHELL) PARM('/QOpenSys/pkgs/bin/php'
/QSYS.LIB/ALAN.LIB/QCMDSRC.FILE/PPHPPARSE.MBR: CMD PROMPT('PHP Log Parser')
/QSYS.LIB/ALAN.LIB/QRPGLESRC.FILE/DB2UTIL.MBR: // PHP API -- start 32bit
/QSYS.LIB/ALAN.LIB/QSOURCE.FILE/SCNXTSRN.MBR: // Program - SCNXTSRN Get Next System Ref. No. USED BY PHP!!!! *

Performance

The primary motivation for developing pfgrep was to dramatically speed up code searches.

For example, for QShell grep to look through all the ILE C and C++ header files for the string ‘Qp01’, it needed 26.963 seconds:

1
2
3
4
5
$ time qsh -c "/usr/bin/grep -R -q Qp0l /QIBM/include"
 
real 0m26.963s
user 0m0.038s
sys 0m0.004s

pfgrep on the same system took only 3.098 seconds:

1
2
3
4
5
$ time pfgrep -r -q Qp0l /QIBM/include
 
real 0m3.098s
user 0m1.733s
sys 0m0.003s

For more examples with PCRE searches, additional command options, and helper utilities pfzip, pfcat, and pfstat, see the pfgrep Github site.

Integration with VS Code for i

Work is being done to integrate pfgrep into Code for i so VS Code users can benefit from its speed and power.

Keep up with the latest in VS Code for i and open source

Come to our free Code for i Fridays meetings and consider a Developer Support contract (VS Code support, pfgrep, PHP, Node, Python, RPG, Git, more) to receive one-on-one mentoring from our team as well as access to Seiden Developer Council meetings.

Tags: IBMi, IBMiOSS, pfgrep, qshell, VS Code
Share this entry
  • Share on Facebook
  • Share on X
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Reddit
  • Share by Mail
https://www.seidengroup.com/wp-content/uploads/2017/03/SeidenLogo-180.png 0 0 Alan Seiden https://www.seidengroup.com/wp-content/uploads/2017/03/SeidenLogo-180.png Alan Seiden2025-03-25 07:30:112025-03-24 15:55:23Physical File GREP (PFGREP): Fast IBM i Source Code Search
Alan Seiden

About Alan Seiden

Alan works to preserve your investment in IBM enterprise systems by designing and implementing modernization strategies that leverage your existing business logic.

With a passion ...Read More

5 replies
  1. shahar mor
    shahar mor says:
    May 8, 2025 at 2:11 pm

    installed it works quite fast . however when source file has “non latin characters” (mine is 424 hebrew) it does not like it and write down “iconv invalid wide characters” altough iconv does work nicely for 424->1208

    Reply
    • Calvin Buckley
      Calvin Buckley says:
      May 8, 2025 at 2:38 pm

      Could you please file a bug report here? https://github.com/SeidenGroup/pfgrep/issues

      If you can, also provide an example file that reproduces the issue.

      Reply
  2. Calvin Buckley
    Calvin Buckley says:
    April 3, 2025 at 3:41 pm

    I replied earlier, but it seems WordPress ate my comment. 🤬

    I don’t have visibility into how IBM did it, but I suspect a lot of it might be how it reads. pfgrep tries to do the I/O for reading the file all at once; it might do encoding conversion or the actual regex match in line based chunks, but file I/O is the heaviest because it involves going to disk and making a lot of round trips through syscalls. It’s quite possible qsh grep is just reading a line at a time when it does its work.

    Reply
  3. Marcela Poenaru
    Marcela Poenaru says:
    March 30, 2025 at 2:59 am

    I have the same curiosity: where does this time difference come from?

    Reply
  4. Glenn Gundermann
    Glenn Gundermann says:
    March 27, 2025 at 3:05 pm

    Why is there such a difference? Under the covers, what is the difference how these two commands work?

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

SUBSCRIBE
Open Thinking
Monthly IBM i Strategy & Tips
  • This field is for validation purposes and should be left unchanged.

IBM i Development

  • RPG, COBOL, SQL, Node,
    PHP, Python, Valance, etc.
  • Modernization. Integration.
  • Web and API Solutions
  • Legacy Maintenance
    ...
LET'S GET IT DONE!

Recent Posts

  • Do You Need IBM i Observability?
  • PHP 8.6 is Coming Soon to IBM i
  • Safer npm installation is on the way for Node.js (and all JavaScript)
  • Access Modern Security for IBM i and Connected Web Environments
  • IBM i: A Natural Platform for Agentic AI
  • PHP on IBM i in 2026: The Modernization Engine
  • Your “AS/400” Is a Modern IBM i Platform
  • MCP + AI for IBM i Teams (with a MongoDB example)
  • GnuPG PHP Extension for IBM i: Now Included with Seiden Support
  • Getting Started with Code for IBM i: A Lunch & Learn Video

SEIDEN GROUP: Modern Development & Open Source for IBM i

Home   |   Seiden PHP+   |   IBM i Services  |   Support   |   VS Code for i   |   Free Stuff   |   Blog  |   Privacy Policy  |   Contact         201.447.2437

© 2026 Seiden Group, LLC
  • Link to LinkedIn
  • Link to Mail
Link to: New QSHONI Commands for SQL and IFS on IBM i Link to: New QSHONI Commands for SQL and IFS on IBM i New QSHONI Commands for SQL and IFS on IBM i Link to: VS Code for IBM i: SELECT Statement [VIDEO] Link to: VS Code for IBM i: SELECT Statement [VIDEO] VS Code for IBM i: SELECT Statement [VIDEO]
Scroll to top Scroll to top Scroll to top