I’ve started using fd to find files (at the command line), instead of the built-in find
. It’s much easier to use and just makes more sense, and it’s fast.
Here’s the old way of changing permissions on a bunch of music files I just bought on Bandcamp. This says “find every file, in this directory and any subdirectories, with a name ending in .flac
, and run chmod 644
on it.” I specify that I just want to work on files because I don’t want to change the perms on a directory of Roberta Flack albums by accident.
find . -name "*.flac" -type f -exec chmod 644 {} \;
New way:
fd .flac -t f -x chmod 644
(I could add a dollar sign and have .flac$
, meaning “end of string” or “end of line” in regular expressions, but I don’t need it. I would use --exec
instead of -x
and --type
instead of -t
in a script, but not if I’m typing a one-off.)
I have this in my ~/.fdignore
file, because otherwise the Zotero folder always turns up matches I don’t want:
Zotero/
This list of modern Unix command replacements is worth checking out. I use ag and btop instead of grep
and top
, but still stick with the built-in less
and ls
.