When I the following command in bash, I get a list of files that match the regular expression I want:
$> ls *-[0-9].jtl
benchmark-1422478133-1.jtl benchmark-1422502883-4.jtl benchmark-1422915207-2.jtl
However, when I run the same command in the fish shell, I get different result:
$> ls *-[0-9].jtl
fish: No matches for wildcard '*-[0-9].jtl'.
ls *-[0-9].jtl
^
How come?
Fish's documentation does not claim to support the full power of POSIX glob patterns.
Quoting the docs:
Wildcards
If a star (*) or a question mark (?) is present in the parameter, fish attempts to match the given parameter to any files in such a way that:
?
can match any single character except/
.*
can match any string of characters not containing/
. This includes matching an empty string.**
matches any string of characters. This includes matching an empty string. The string may include the/
character but does not need to.
Notably, there's no mention of character classes, as fish doesn't support them.
If you want globs guaranteed to support all POSIX (fnmatch) features, use a POSIX-compliant or POSIX-superset shell.
You can also use more extended tool unix find
. It is very powerful.
example: use regular expressions
find . -path '.*-[0-9].jtl' -not -path '.*-32.jtl'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With