Reputation: 1115
I have the following simple bash script:
#!/bin/bash -fx
ls *sh
The problem is that bash add a quote to the pattern and I get wrong output.
+ ls '*sh'
ls: cannot access *sh: No such file or directory
How can I change this behavior?
The output of ls *sh
from the terminal is:
$ls *sh
a.bash a.sh b.sh
I tried to add quotes according to this post - "Bash variable containing file wildcard" without success
Upvotes: 0
Views: 333
Reputation: 8521
That because you're disabling pathname expansion
with the -f
option.
#!/bin/bash -fx
From man:
-f
Disable filename expansion (globbing).
Upvotes: 8