Help File
Wish List


Hosted by:
  VA Linux


Hawk / Ftwalk Comparisons: Find

Ftwalk was originally conceived as a replacement for find: the venerable UNIX program that searches for files from an arbitrary point, selects files according to a command line expression, and performs actions by invoking other shell commands.

Ftwalk has straightforward replacements for every feature of SVR4 find (except for -cpio). Ftwalk has several advantages:

  • Ftwalk takes any number of test expressions, each with its own distinct action block. Find is limited to a single expression.
  • Ftwalk actions can be crafted from hundreds of built-in functions, user-defined functions, and general programming constructs, where find is limited to calling shell commands or printing pathnames.
  • Ftwalk scripts are significantly more readable then find expressions, which depend on the shell for lexical analysis and either eschew shell metacharacters or require special quoting.
The following table shows the find expressions and their simplest Ftwalk equivalents. There are three groups of expressions: 1) file name or attribute tests; 2) actions; 3) option switches which control the search methodology.

Find Expression Ftwalk Expression Description/Notes
-name pattern name( pattern ) Match filename using shell patterns. Ftwalk can also specify same as: name == string; name ~ pattern (shell pattern string or regular expression).
-perm [-]num perm([-]num) Test file permission bits. If negative, only test specified bits. Ftwalk can also specify same as: perm == num; (perm & num) == num.
-size [±]n sizeb op n Compare file size in 512-byte blocks. Find uses + for >, - for <, neither for ==. Ftwalk uses any relational operator: <, <=, ==, !=, >, >=.
-size [±]nc size op n Compare file size in bytes.
-atime [±]n atime op n Compare file access time in days ago.
-ctime [±]n ctime op n Compare file creation time in days ago.
-mtime [±]n mtime op n Compare file modify time in days ago.
-newer path newer( path ) True if file modify time is more recent than reference file.
-anewer path anewer( path ) True if file access time is more recent than reference file.
-cnewer path cnewer( path ) True if file creation time is more recent than reference file.
-type b isblk True if file is block special.
-type c ischr True if file is character special.
-type d isdir True if file is directory.
-type f isreg True if file is regular file.
-type l islnk True if file is symbolic link.
-type p isfifo True if file is named pipe (FIFO).
-inum n inum == n True if file has inode number.
-links [±]n links op n Compare number of links to file.
-user uid user == uid True if file belongs to user.
-group gid group == gid True if file belongs to group.
-nouser nouser True if file owner is not in /etc/passwd.
-nogroup nogroup True if file group is not in /etc/group.
-fstype type fstype == type True if file system type matches.
Expressions which in Ftwalk would normally occur in action blocks.
-print print Print file pathname to stdout. Ftwalk default if no action block.
-exec cmd ... \; sh( cmd ) Execute shell command. Use {} to substitute current pathname.
-ok cmd ... \; oksh( cmd ) Like -exec and sh, except prompts user before executing command.
-prune prune Restricts file search to exclude directories below the current file.
Options which control file search methodology. Also available in Ftwalk as command line option switches.
-depth depth Enables depth-first file tree search.
-mount mount Restricts search to initial file system directories.
-local local Restricts search to file systems on local machine.
-follow follow Causes file search to follow symbolic links.

GNU find has a number of additional features, which need to be reviewed and charted. Most of these appear to have equivalent support in ftwalk, although the translation may be less straight forward.