Sun, Sep
3 New Articles

TechTip: The Find Object (FND) Command for the Integrated File System

Programming - Other
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Search the IFS for objects by name and type—excluding the file systems or directories you wish—and save the result to a database file.

Have you struggled to find certain objects in the IFS? This command solves the problem.

The main characteristics of the Find Object (FND) command are the following:

  • The object name specified in the search can be a regular expression.
  • A list of file systems and/or directories can be excluded from the search.
  • Symbolic links pointing to directories can be followed or not.
  • Multiple paths to the same directory can be searched or not.
  • A sort sequence can be specified to determine the order in which matches found are shown and the order in which subdirectories of a directory are searched.
  • The search result can be sent to the display, a printer file, or a database file.
  • The log generated in the process can be sent along with the result or printed to a separated spool file.

This command can be downloaded for versions 7.1 and 7.3 in English and Spanish. <- Kara, please put the zip files into the two links. Note the “en” for English and “es” for Spanish.

FND Parameters

The parameters of the command are shown in Figures 1 and 2:

TechTip: The Find Object (FND) Command for the Integrated File System - Figure 1

Figure 1: Parameters of command FND, part 1

TechTip: The Find Object (FND) Command for the Integrated File System - Figure 2

Figure 2: Parameters of command FND, part 2

The Search

The search in a directory first examines the objects contained in the directory. Then, if it has been specified to search the subdirectories of directories (parameter SUBTREE), the search continues in these subdirectories in the order specified in the sort sequence (parameter SRTSEQ).

For every directory, the objects that match the name and type specified are listed in the order indicated in the sort sequence.

When a directory can be reached through different paths, the objects contained in this directory might appear several times in the search result. Parameter MLTPATH (search multiple paths) specifies whether all of the paths to a directory are searched—as the UNIX command find does—or only one of them (the first one reached according to the search order).

Regular Expressions

The patterns allowed in the object name are the extended regular expressions (EREs) used in the UNIX commands awk, ed, and grep. These expressions are similar to those used in the SQL predicate REGEXP_LIKE.

Some of the special characters used in these regular expressions are the following:


Special Characters for Regular Expressions


. (dot)

Any character


The preceding item can appear 0 or 1 times


The preceding item can appear 0 or more times


The preceding item must appear 1 or more times


Beginning of line/name


End of line/name


Removes the special meaning of a special character




Any character that is not a digit


Generic space—that is, space, tab, end of line, line feed, or carriage return


Any character that is not a generic space


Any of the preceding or following items (OR)




Any of the characters enclosed in brackets


Any character not enclosed in brackets


Range of characters


Any character out of the range of characters

Regular expressions are managed through the procedures regcomp, regexec, and regfree of service program QC2POSIX. Documentation about these procedures can be found in the IBM i handbook ILE C/C++ Runtime Library Functions.

The prototypes for these procedures are listed in member REGEX of file QSYSINC/H. These prototypes, converted to RPG, can be downloaded along with the command FND.

Object Types

The types of objects specified (parameter OBJTYPE) can be of the file system QSYS.LIB (*FILE, *PGM, etc.) or other file systems. The object types not belonging to QSYS.LIB are the following:


Object Types Not in QSYS.LIB



Block special file


Character special file


Distributed directory






Distributed stream file


First-in-first-out special file






Stream file


Symbolic link

The special values for parameter OBJTPE are the following:


Special Values for OBJTYPE



Any type


Any directory (*DDIR, *DIR, *FILE, *FLR, *LIB)


Any type that is not a directory

File Systems Excluded

Parameter EXCFS allows us to specify the file systems that are going to be excluded from the search. The values used to refer to file systems are the following:


File Systems



Network file systems (NFS). Remote.


Document library services file system (QDLS)


File server file systems (QFileSvr.400). Remote.


NetClient file systems (QNTC). Remote.


Open Systems file system (QOpenSys)


Optical file system (QOPT)


Library file system (QSYS.LIB)


Independent ASP library file systems


User-defined file systems


User-defined management file systems


Remote file systems (*NFS, *QFSVR400, *QNTC)

The default value for this parameter is *NONE, but, if the command is prompted, all of the file systems except root and QOpenSys will be included in the parameter (see Figure 1). This can be useful if you search the UNIX-like file systems most of the time.

However, these values—and any other default value for the other parameters—can be altered by changing the prompt override program of the command. An example of this program is shown next:

                   PGM       PARM(&C_CMD &C_PARM)

/* */

             DCL       &C_CMD        *CHAR    20

             DCL       &C_PARM       *CHAR   202

             DCL       &EOL          *CHAR     1

             DCL       &EXCFSKWD     *CHAR    15

             DCL       &EXCFSVAL     *CHAR   100

             DCL       &PARMLEN      *DEC      3

/* */

             MONMSG     MSGID(CPF0000) +

                        EXEC(GOTO CMDLBL(ERRORS))

/* */

             CHGVAR     &EOL X'00'

             CHGVAR     &EXCFSKWD '??EXCFS('

             CHGVAR     &EXCFSVAL +


             CHGVAR     &C_PARM (' ' *CAT &EXCFSKWD *TCAT &EXCFSVAL)

/* */

             CHGVAR     &C_PARM (%trimr(&C_PARM) *CAT &EOL)

             CHGVAR     &PARMLEN (%scan(&EOL &C_PARM) - 3)

             CHGVAR     %bin(&C_PARM 1 2) &PARMLEN

/* */



             CHGVAR     &C_PARM X'0000'



You can find more information about prompt override programs in the IBM i handbook CL Overview and Concepts.


The search result can be sent to the display, a printer file, or a database file. Figure 3 shows an example of output sent to the display or a printer file:

TechTip: The Find Object (FND) Command for the Integrated File System - Figure 3

Figure 3: Example of output for command FND

The first seven lines of the result of Figure 3 (from lib_data.h to zlib.h) correspond to the entries of directory /qopensys/usr/include, and the next lines to the entries of its subdirectories.

If the output is directed to a database file, this file is created with the following format:


Format of Output File









Object type








Object path


Parameter LOG specifies whether a search log is kept or not as well as whether it is sent along with the search result or printed to a separate spool file.

The events that can be included in the log are the following:


Log Events



Directory duplicated, that is, already searched


Error in checking object


Error in closing directory


Error in comparing object name


Error in opening directory


Error in reading directory entries


Excluded directory


Excluded file system


Name too long


Path too long


Searching this directory would cause a loop


Not authorized to object


Object is not a directory


Object not found

The FND command helps you find the objects in the IFS that you’re looking for. Enjoy!

Juan Macias

Juan Macias has a Degree in Mathematics (1988) and a Master in Data Management from the Universidad Complutense de Madrid (1989). He's a developer of RPG and COBOL applications mainly for finance and insurance companies. He can be contacted at This email address is being protected from spambots. You need JavaScript enabled to view it..



Support MC Press Online

$0.00 Raised:

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: