ff: the find-fix utility.
ff is a utility command-line tool (and lua library) to find and optionally
replace lua patterns. It searches for file patterns, file content, or both. It
can also rename files and modify the content using
--sub with
--mut.
ff uses an easy to learn shorthand for many operations, displayed below:
| syntax |
equivalent |
| some_pat (no prefix) |
--pat=some_pat |
| r:some/dir/ |
--root=some/dir |
| p:path.*pattern |
--path=path.*pattern |
| -p:%.so$ |
--nopath=%.so$ |
Examples:
ff 'some.*pattern' # search for some.*pattern
ff r:some/root/ pat # search for pat in root
ff find --sub=fix # replace 'find' with 'fix' (display)
ff find --sub=fix --mut # actually replace 'find' with 'fix'
Note: all
directories/ always end with
/ which you can
use to include/exclude them.
When called in lua, returns a list of paths which matched
all requirements.
Arguments:
- .root
list of root paths, i.e. r:path1/ r:path2
- .pat
list of patterns to find
- .nopat
list of (file-wide) pattern exclusions
- .path
p:%.lua list of file path patterns
- .nopath
-p:%.bin list of file path patterns to exclude.
default: exclude dirs starting with '.'. Disable default by setting
to an empty string, i.e. --nopath=
- .sub
the subsitution string to use with pat
- .mut
mutate files (used with sub)
- .dirs
show all non-excluded directories
- .content =true
if false do not show content (only show paths)
- .pathsub
the substitution string to rename the path.
Note: this implies content=false and cannot be used with sub
Methods
- fn:iter() -> iter
Get an iterator of matching paths.
Usage: for path, pty in FF:new{...}:iter() do ... end