4 ms·
I love fd, but somehow I always get tripped up on this: fd # prints tree of current directory fd somedir/ # results in an error find
by eterps 4y ago
I love fd, but somehow I always get tripped up on this:
fd # prints tree of current directory
fd somedir/ # results in an error
find # prints tree of current directory
find somedir/ # prints tree of somedir/
- geodel 4y agoAh, same thing happens to me all the time. You are right, second one seems more intuitive and many tools old and new use this pattern.
- Johnny555 4y agoThat seems unfortunate, since my shell's autocomplete puts that trailing slash in there by default.
- eterps 4y agoThe trailing slash is not the issue here. With `fd` the first argument is the pattern to search for, not the starting point like in `find`. For example to find fonts.conf below /etc, with fd you would do: fd fonts.conf /etc And with find: find /etc -name fonts.conf In other words with find the first argument is always the starting point. And leaving it out implies the current directory as the starting point.
- joveian 4y agoThere are --search-path and --base-path options, so if you alias say fd='fd --search-path' you can then have the required first argument be the path to search. Personally, I find changing to the directory I want to search in less annoying than typing out the directory to search (I know the options exist from script use).
- mekster 4y agoIf it wasn't for find's muscle memory, fd has it right as you'd usually list what you want to do in the cli first and then list arbitrary number of targets in the end.