Fd: [solved] fd is unable to locate the file named ... without others with three dots in the filename

Created on 7 Mar 2018  Β·  5Comments  Β·  Source: sharkdp/fd

$ touch ... ...0
$ ls -a
. .. ... ...0
$ find -name ...
./...
$ fd -FH ...
...
...0
$

question

Most helpful comment

Oh, that’s really great! Thank you for your support.
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
SOLVED!

All 5 comments

Which shell are you using? Note that some shells treat the unescaped ... as an alias for ../... zsh does this, for example:

zsh> echo ...
../..

This, in turn, leads fd -F to search for the string literal ../.. - which will not be found.

The following works for me in both zsh and bash:

β–Ά touch '...'

β–Ά fd -H
...

β–Ά fd -FH '...'
...

β–Ά touch '...0'

β–Ά fd -H
...
...0

β–Ά fd -FH '...'
...
...0

This looks perfectly fine for me?

I use bash.
The issue is that you cannot locate ONLY the file ... without getting other files with three dots in their filenames in the output of fd.

If you have _thousands and thousands of files with three dots in the filenames_, how do you find the file with the filename ... using fd? The output will be very long.

If you use find like this:

$ find -name ...
./...
$

it locates exactly what you're searching for: the file ... while ignoring other files having ... in their filenames.

In other words, if you have files bb, abbc, aabbcc, you can locate the file bb by using regex ^bb$ like this:

$ ls
aabbcc abbc bb
$ fd bb
aabbcc
abbc
bb
$ fd ^bb$
bb
$

But you _cannot_ do like this with the file named ... because in this case you have to use the option -F which does not let you use regexes.

But you cannot do like this with the file named ...

You can still use a regex, you just have to escape the dots:

fd '^\.\.\.$'

or

fd '^\.{3}$'

Another option is to use a character class […] with just a single entry:

fd '^[.]{3}$'

Oh, that’s really great! Thank you for your support.
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
SOLVED!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

christianbundy picture christianbundy  Β·  3Comments

nishithkhanna picture nishithkhanna  Β·  4Comments

ChengCat picture ChengCat  Β·  3Comments

hungptit picture hungptit  Β·  3Comments

sharkdp picture sharkdp  Β·  3Comments