File Lister

Download from

The File Lister (FL) implements some of the functionality seen in programs such as UNIX find.

It is also a simple test harness for my Directory Traversal and Extended Regular Expression, libraries. As DIRT has been implemented on a variety of operating systems, FL is available on a similar wide variety of operating systems.


usage: fl [-n ere|-N glob] [-x ere|-X glob] [-y ere|-Y glob] [-r]
          [-j|-J] [-t types] [-s] [-o output] [-c command] [-q] [--] {filespec}
flags: -n ere      list pathnames whose basenames match ere
       -N glob     list pathnames whose basenames match UNIX style glob
       -x ere      exclude files whose basenames match ere
       -X glob     exclude files whose basenames match UNIX style glob
       -y ere      exclude directories whose basenames match ere
       -Y glob     exclude directories whose basenames match UNIX style glob
       -r          recursive directory search
       -j -J       case insensitive pathname match, or sensitive
                   (default: sensitive on UNIX)
       -t types    letters indicating types of filesystem entry to list
                   f    files
                   d    directories
                   b    block devices
                   c    character devices
                   F    FIFOs
                   s    sockets
                   o    other
       -s          sort matches
       -o output   letters controlling the output format
                   p    include path
                   n,f  include filename
                   e,x  include extension
                   l    force to lower case
                   u    force to upper case
                   /    force to forward slashes
                   \    force to backward slashes
                   v,V  output in Virtual Fold format
       -c command  execute command rather than display match
       -q          don't show some error messages
       filespec    filespec(s)

The filespec identifies the files and or directories to list.

If -r is specified, any directories are recursively searched.

The -n ere or -N glob can be used to filter filenames to just those that match the pattern.

The -x ere or -X glob can be used to exclude files from the output. eg: -X "*.bak".

The -x ere or -Y glob can be used to exclude directories (and anything below them) from the output. eg: -Y .svn.

-j or -J can be used to force the pattern matching to be case sensitive or not. The default is the most sensible choice for the platform, but it is acknowledged that systems can sometimes 'mount' each others disks.

The -t types argument can be used to ensure that only filesystem entries of particular types are considered matches. The set of valid types listed above comes from the UNIX version of FL, and is different on each platform (eg: Windows doesn't have block devices).

Once all the matches have been determined, it is possible to sort them into ASCII order using the -s argument.

Normally FL outputs the whole matching name, comprised of all the elements making it up (typically, drive, path, name and extension). The -o option can be used to restrict what gets output.

Names are considered to be comprised of the following elements :-


Just because you ask for the path in the output doesn't mean you'll get it. If the file is found in the current directory using a filespec that didn't full qualify the path to the current directory, then the path isn't present in the output. The output flags simply mean "if its present in the output, then show it".

On UNIX, there is no d: component, and the path seperators are /s.

Rather than simply display the output, it can be substituted into a command (where #s appear), and the commands executed instead.


List all C source and header files :-

fl *.c *.h

List all C source and header files (alternative syntax, using a glob). Internally FL converts the glob to the equivelent ERE :-

fl -N "*.[ch]" *

List all C source and header files (alternative syntax, using an ERE). Note that ^ and $ anchors are implied, and that using EREs there is the scope to perform much more sophisticated matching :-

fl -n ".*\.[ch]"

List all Java source files in this directory and below :-

fl -N "*.java" -r *

List files and directories in this directory and below, but omit other filesystem entries, such as FIFOs, sockets etc. :-

fl -t fd -r *

Find all the Java source files, and display them with forward slashes (which isn't the default on non-UNIXes) :-

fl -N "*.java" -r -o pnel *

Find all the GIF files in the current directory, and execute a command which creates an equivelent TIFF file :-

fl -o pn -c "gbmref #.gif #.tif"


Wildcard confusion

There are several kinds of wildcard in use here :-

Operating System native filename wildcard.
As used for the filespec arguments. Varies depending upon the platform you're running on. These can be UNIX globs, or non-UNIX wildcards.
UNIX globs.
As used for the -N glob argument (regardless of where you are running FL), and for the filespec arguments (if you're running FL on UNIX). These support ? to mean any character, * to mean zero or more of any character, and [ ] enclosed character sets/ranges.
non-UNIX wildcards.
As used for the filespec arguments if running non-UNIX. A subset of UNIX globs. Typically supporting ? to mean any character, * to mean zero or more of any character. On 32 bit OS/2 wildcard expansions only include files, and do not include directories. On DOS, * doesn't work the middle of the wildcard either. On 32 bit DOS, I've not been able to get any wildcard to work.
As used for the -n ere argument. Full Extended Regular Expression syntax supported.

You need to be sure you're using the right kind of pattern in the right place, otherwise unexpected results will be obtained.

filespec argument

The following does not list all C files in this directory and its subdirectories :-

fl -r *.c

In fact, it lists all C files in this directory, and all files in any subdirectory that happens to have a name ending in .c! It may not even do this (see section above).

Just as in UNIX, using find, you'd say :-

find . -name '*.c'

When using FL you can say :-

fl -N "*.c" -r .


There are so many metacharacters involved here, that you're just bound to fall foul of the quoting requirements of your shell or command processor.


This program, including its source code, are public domain. Caveat Emptor.

This documentation is written by the FL program author, Andy Key