# fd Cheat Sheet Installation ``` $ sudo apt install fd-find $ cargo install fd-find ``` ``` fd --version fd 8.1.1 fd --help # shows manmpage ``` From Sudeshna Sur, Replace find with fd on Linux, June 2021 https://opensource.com/article/21/6/fd-linux ``` $ fd $ fd [str] $ fd [str] [dir] $ fd . '/home/ssur/exa' -e md $ fd -e zip -x unzip # run unzip for each found file (--exec) $ fd -e md -X "wc -l" # run "wc -l" once with all files as argument (--exec-batch) $ $ fd . '/home/ssur/Work/' --changed-within 10d $ fd . '/home/ssur/Work/' --changed-before 365d ``` From github page: ``` fd '^x.*rc$' # same regex syntax as rg fd passwd /etc # specify root dir fd . fd/tests/ # catch-all pattern (or ^) fd -e rs mod # search all files ending in .rs with 'mod' in filename fd -g libc.so /usr # find exactly 'libc.so', -g is "glob" fd -H pre-commit # search in hidden dirs and show hidden files fd -I num_cpu # does not ignore .gitignore fd -p -g '**/.git/config' # match against full path fd -p '.*/lesson-\d+/[a-z]+.(jpg|png)' # match against full path fd … -X ls -lhd --color=always # equivalent to fd -l fd -g 'test_*.py' -X vim fd -e cpp -e cxx -e h -e hpp -X rg 'std::cout' # fd + rg # {} = search result, {.} = without extension fd -e jpg -x convert {} {.}.png # convert .jpg to .png fd -H -E .git … # exclude dir fd -E '*.bak' … # exclude file type fd -H '^\.DS_Store$' -tf -X rm # remove all .DS_Store files (or 'rm -i') ``` Placeholder syntax (similar GNU parallel) ``` {}: A placeholder token that will be replaced with the path of the search result (documents/images/party.jpg). {.}: Like {}, but without the file extension (documents/images/party). {/}: A placeholder that will be replaced by the basename of the search result (party.jpg). {//}: The parent of the discovered path (documents/images). {/.}: The basename, with the extension removed (party). ``` Without placeholder, fd adds {} at end. Various options ``` -u same as -I, --no-ignore -uu same as --no-ignore --hidden -j, --threads number of threads for search and exec ``` Output as tree Install https://github.com/jez/as-tree fd | as-tree Alternative: ``` fd | tree --fromfile fd --extension rs | tree --fromfile alias as-tree='tree --fromfile' ```