Install fd as a simple and user-friendly alternative to find
.
Install fd
utility.
$ sudo apt install fd-find
Display short help information, use --help
option to get more details.
$ fdfind -h fd 8.1.1 USAGE: fd [FLAGS/OPTIONS] [<pattern>] [<path>...] FLAGS: -H, --hidden Search hidden files and directories -I, --no-ignore Do not respect .(git|fd)ignore files -s, --case-sensitive Case-sensitive search (default: smart case) -i, --ignore-case Case-insensitive search (default: smart case) -g, --glob Glob-based search (default: regular expression) -a, --absolute-path Show absolute instead of relative paths -l, --list-details Use a long listing format with file metadata -L, --follow Follow symbolic links -p, --full-path Search full path (default: file-/dirname only) -0, --print0 Separate results by the null character -h, --help Prints help information -V, --version Prints version information OPTIONS: -d, --max-depth <depth> Set maximum search depth (default: none) -t, --type <filetype>... Filter by type: file (f), directory (d), symlink (l), executable (x), empty (e), socket (s), pipe (p) -e, --extension <ext>... Filter by file extension -x, --exec <cmd> Execute a command for each search result -X, --exec-batch <cmd> Execute a command with all search results at once -E, --exclude <pattern>... Exclude entries that match the given glob pattern -c, --color <when> When to use colors: never, *auto*, always -S, --size <size>... Limit results based on the size of files. --changed-within <date|dur> Filter by file modification time (newer than) --changed-before <date|dur> Filter by file modification time (older than) -o, --owner <user:group> Filter by owning user and/or group ARGS: <pattern> the search pattern - a regular expression unless ';--glob'; is used (optional) <path>... the root directory for the filesystem search (optional) Note: `fd -h` prints a short and concise overview while `fd --help` gives all details.
Search for go
files, but ignore vendor
directory.
$ fdfind --exclude vendor --extension go src/background/background.go src/background/ssh.go src/configuration/configuration.go src/configuration/yaml.go src/crio-top/main.go src/terminal/terminal.go
Search for go
files inside src/terminal/
directory.
$ fdfind --extension go . src/terminal src/terminal/terminal.go
By default .gitignore
files are respected.
$ cat bin/.gitignore **
This means that you will find nothing there.
$ fdfind . bin
Unless you ignore .gitignore
files.
$ fdfind --no-ignore . bin bin/crio-top
List details of executable files.
$ fdfind --list-details --no-ignore --type x -rwxrwxr-x 1 milosz milosz 5,5M maj 29 17:47 bin/crio-top
Print only the first file with size greater then 2k
located on the same filesystem, but ignore vendor
directory.
$ fdfind --one-file-system --exclude vendor --max-results 1 --size +2k readme.md
Display files changed within the last 2 hours.
$ fdfind --type f --changed-within 2h readme.md src/crio-top/main.go
Perform action on found files.
$ fdfind --type f --changed-within 2h --exec echo File \'{}\' located in \'{}\' File 'readme.md' located in '.' File 'main.go' located in 'src/crio-top'
Open located files inside vim
.
$ fdfind --type f --changed-within 2h --exec-batch vim
There is more to it, but this should get you started.