Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use recursive wildcards in fish shell for dotfiles and -folders?

The recursive wildcards in fish are extremely useful. But if I want to use it for files or directories with a leading dot it's not working.

For example:

folder
├subfolder
│ └test.txt 
├.subfolder
│ └test.txt
├test.txt
└.test.txt

If I now run ls -a **.txt the output shows only the test.txt files which are not in a folder with a leading dot or are not dotfiles by itself. (output: subfolder/test.txt test.txt)

How can I fix that?

like image 446
miu Avatar asked Jan 29 '26 18:01

miu


1 Answers

This is fish issue #1568.

There is currently no short way to do this, the long ways are:

  • Use external programs (like find)

or

  • Do a more complicated glob like this one:

    ls -a **.txt .*.txt **/.*.txt

These match, in order: non-dotfiles, dotfiles in the current directory, dotfiles in subdirectories.

like image 115
faho Avatar answered Jan 31 '26 20:01

faho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!