code / wheres

Lines496 YAML273 C178 Markdown33 make12
(45 lines)

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.

1 # Where's: A simple file finder
3 `wheres` is a simple tool for finding where a file or directory is.
4 `wheres` is like if `find` had a sane interface and worked better.
6 |`find` | `wheres` |
7 |-----------------------------------|-----------------------------------------|
8 |`find -name foo.c` | `wheres foo.c` |
9 |`find /foo /baz -name foo.c 2>/dev/null` | `wheres /foo /baz foo.c` |
10 |`find -name foo.c -or -name baz.c` | `wheres foo.c baz.c` |
11 |`find -iname 'readme*'` | `wheres -i 'readme*'` |
12 |`find -regex '.*/foo\(\.c\)?'` | `wheres 'foo*' | grep '.*/foo\(\.c\)?'` |
14 ## Some differences
16 ### No error messages
18 `wheres` does not print file access errors, it silently ignores directories
19 whose contents can't be read. For example, searching inside `/`, will not spam
20 the console with useless access errors when not run as root.
22 ### Default directory
24 `wheres` operates in the current working directory by default, which can be
25 overridden using the `-d` flag to set the working directory. You do not need to
26 specify the directory first.
28 ### Patterns are the main argument
30 Positional arguments to `wheres` act as globbing patterns and if _any_ pattern
31 matches a filename, it will be printed, rather than `find`'s default logic that
32 requires _all_ patterns to match a filename. There is no `-or`/`-and` flags for
33 complex boolean logic.
35 ## Usage
37 * `--help,-h`: print a help message
38 * `--dir,-d <dir>`: search in a given directory
39 * `--ignorecase,-i`: search case-insensitively
40 * `--type,-t <type>`: search for (f)iles, (d)irectories, (l)inks, (p)ipes, (s)ockets, (b)lock devices, (c)haracter devices
41 * `--nul,-0`: print a nul byte instead of a newline after each match
43 Positional arguments are treated as patterns to search for, unless they contain
44 a `/` or are one of the literal values `.`, `..`, `~`, in which case they're
45 treated as paths to search from.