First of all thank you for this. It's really fast and i'm already loving it!:)
I think fd should allow for exact find probably using some flag. A use case i can use to explain is when searching for error_log files.
Using fd error_log returns:
/some/folder/open_basedir_error_log.phpt
/another/folder/open_basedir_error_log_variation.phpt
/new/folder/name/random_string_before_error_log.old
/new/folder/name/random_string_before_error_log.temp
/new/folder/name/jibberish_error_log_readme_first.txt
You can see how for example you can't use xargs to delete as you might delete files that are actually in use by something else.
Thanks.
First of all thank you for this. It's really fast and i'm already loving it!:)
Thank you for the feedback!
I think fd should allow for exact find probably using some flag. A use case i can use to explain is when searching for error_log files.
Note that the search pattern in fd is always a regular expression, so in a situation like this, I just use:
> fd '^error_log$'
What do you think?
for comparison, ripgrep has -F or --fixed-strings flag to treat the pattern as a literal string instead of regular expression. When this flag is used, the special regular expression meta characters such as (){}*+. do not need to be escaped.
There's also -g, --glob <GLOB>... to include/exclude files for searching in ripgrep. It's using glob pattern instead of regular expression. You can do exact file name matching using this.
Agreed, -F/--fixed-strings sounds like a useful addition.
Concerning --glob: @iology implemented a version of this in his fork here: https://github.com/jakwings/ff-find
Note that the search pattern in fd is always a regular expression, so in a situation like this, I just use:
fd '^error_log$'
I think your option is clever enough. However, while i had to open an issue for this (after reading the help and other issues) i wonder if this won't happen in the future. While providing a new flag to use this might seem a little more work -- i think in the long run it'll just be more easier to use and discover this..
About the pros and cons of a glob pattern compared to a fixed string: The special chars * ? { } \ in glob patterns are seldom used in pathnames (except [ ]). Other than this glob patterns are more powerful than fixed strings while still safer to use than regex patterns.
One biggest problem of fd and my ff is that it does not warn users about the magic of regex. (I'll suggest people to use --glob and make it the default.)
For better interactive experience I would suggest fzf. 馃槈
I don't think searching for a fixed string is worth adding an extra option here. It is easier to memorize that fd always search by regex, and that ^xxx$ means an exact string in regex, than to memorize an extra option.
Just to clarify, fixed string in this context isn't equal to exact find. Fixed string just means a regular searching without treating regex meta character as special.
Thanks for the clarification.
for comparison, ripgrep has -F or --fixed-strings flag to treat the pattern as a literal string instead of regular expression. When this flag is used, the special regular expression meta characters such as
(){}*+.do not need to be escaped.
However, do we actually use (){}* in file names? The only useful characters seem to be .[]. I am not sure whether this is worth introducing an extra kind of pattern.
This flag is much more useful for ripgrep, since it searches file contents, rather than file names.
At least () is used quite often. For example if you download and save a file with the same filename in Firefox, you get:
file.txt
file(1).txt
file(2).txt
Fix released in v6.3.0
Most helpful comment
Thank you for the feedback!
Note that the search pattern in fd is always a regular expression, so in a situation like this, I just use:
What do you think?