1

I'm using bash. Suppose I have a file named filelist, which contains a list of files:

stuff/**/*.csv # to keep it simple (without loops), assume just one entry #*.txt #foo.md #bar.bin 

And I want to expand that:

ls $(cat filelist) 

I get:

ls: cannot access 'stuff/**/*.csv': No such file or directory

What I want is to expand that into a list of files which I can pipe to my main app for processing. How can I do that?

8
  • The last command work fine for me. What is the result of set -o|grep glob? Commented Dec 30, 2023 at 8:42
  • @RomeoNinov noglob off Commented Dec 30, 2023 at 11:50
  • @ilkkachu bash (it's already noted as a tag). I'll add that to the question text too. Commented Dec 30, 2023 at 12:25
  • 1
    @lonix my guess is that you expect ** to do recursive globbing, right? But that needs to be enabled in bash; check the output of shopt for globstar! Commented Dec 30, 2023 at 13:58
  • 1
    @lonix, yes, I wondered why the output of set -o mentioned above wouldn't show the other glob-related options, and jumped to expect you'd be running some non-Bash shell by mistake (people do that a lot with scripts). But of course e.g. globstar isn't a set -o option, but a shopt option, sigh. So yeah, my bad, sorry about that. Commented Dec 30, 2023 at 14:34

1 Answer 1

4

My guess is that you expect ** to do recursive globbing, right? But that's not enabled by default in Bash and needs to be enabled via shopt -s globstar (similarly to dotglob and extglob). You can also check the value with shopt globstar.

(Or shopt |grep glob to echo the suggestion of set -o |grep glob in the comments; note the difference between shopt and set -o here.)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.