Fd: Can not find file without extension

Created on 22 Oct 2020  Â·  4Comments  Â·  Source: sharkdp/fd

Describe the bug you encountered:

Though the folder has few files without extension, but the following command returns nothing.

$ fd -t f -e ''

Describe what you expected to happen:

I expected to have a output ~similar to the output of find . -type f ! -name "*.*"

What version of fd are you using?
fd 8.1.1

Which operating system / distribution are you on?
Linux 5.4.0-52-generic x86_64
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20
Release: 20
Codename: ulyana

documentation good first issue question

All 4 comments

Interesting. I had never thought about -e ''. I guess we could/should support this.

Another way to achieve the same thing would be:

fd -t f --exclude '*.*'

or using a regex:

fd -t f '^[^.]+$'

-e '' currently finds all files which end in a period (.), i.e. have an empty extension. Changing this to finding all files without an extension would be breaking. On the other hand, files that end in a period are pretty rare.

We could alternatively add another argument --no-extension that finds all files without an extension.

-e '' currently finds all files which end in a period (.), i.e. have an empty extension.

oh, of course :+1:

Changing this to finding all files without an extension would be breaking.

Right. And potentially confusing, even if it's unlikely that someone actually wants to search for empty extensions (as opposed to no extensions).

We could alternatively add another argument --no-extension that finds all files without an extension.

Or maybe just extend the --help text of -e/--extension?

"… If you want to search for files without extension, you can use the regex pattern '^[^.]+$'."

I think a --no-extension shorthand would be more convenient, though maybe this case is rare enough that a new flag isn't necessarily worth it.

If it would be worth it, I have created a PR #677 to add the flag. Though of course feel free to close if you disagree, ha.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

runiq picture runiq  Â·  3Comments

blueray453 picture blueray453  Â·  3Comments

sharkdp picture sharkdp  Â·  3Comments

codyro picture codyro  Â·  4Comments

mwgkgk picture mwgkgk  Â·  3Comments