code / wheres

Lines496 YAML273 C178 Markdown33 make12

Where's: A simple file finder

wheres is a simple tool for finding where a file or directory is. wheres is like if find had a sane interface and worked better.

find wheres
find -name foo.c wheres foo.c
find /foo /baz -name foo.c 2>/dev/null wheres /foo /baz foo.c
find -name foo.c -or -name baz.c wheres foo.c baz.c
find -iname 'readme*' wheres -i 'readme*'
find -regex '.*/foo\(\.c\)?' wheres 'foo*' | grep '.*/foo\(\.c\)?'

Some differences

No error messages

wheres does not print file access errors, it silently ignores directories whose contents can't be read. For example, searching inside /, will not spam the console with useless access errors when not run as root.

Default directory

wheres operates in the current working directory by default, which can be overridden using the -d flag to set the working directory. You do not need to specify the directory first.

Patterns are the main argument

Positional arguments to wheres act as globbing patterns and if any pattern matches a filename, it will be printed, rather than find's default logic that requires all patterns to match a filename. There is no -or/-and flags for complex boolean logic.

Usage

  • --help,-h: print a help message
  • --dir,-d <dir>: search in a given directory
  • --ignorecase,-i: search case-insensitively
  • --type,-t <type>: search for (f)iles, (d)irectories, (l)inks, (p)ipes, (s)ockets, (b)lock devices, (c)haracter devices
  • --nul,-0: print a nul byte instead of a newline after each match

Positional arguments are treated as patterns to search for, unless they contain a / or are one of the literal values ., .., ~, in which case they're treated as paths to search from.