Hallo Ralph,
Am 03.10.26 um 13:02 schrieb Ralph Seichter via Fish-users:
I wonder about the fish equivalent of calling `rm [b-k]*` in a Bash session.
fish does indeed not have the […]-globs.
I didn't even know Bash had those, and tbh I'm not convinced they are that
useful, since they only match one char. For anything more complex than the * or
** globs I'd indeed use `find` or `fd` (a modern alternative to find with a
much more intuitive syntax, see [2]).
The only fish-native commands that supports regex is `string`, so the shortest
fish-only equivalent would probably be
`rm (string match -r '^[b-k].*' *)`
Note that this is full regex syntax, so it needs the ^ for start of the string.
You can combine that with `path filter` if you want to filter out directories
or symlinks.
Alternatively, Fish also supports {}-brace expansion, so you could write
`rm {b,c,d,e,f,g,h,i,j,k}*`
– more repetitive, but maybe even faster to type (and less to think about).
Most missing Bashisms can be worked around with the builtin commands [1];
especially `string`, `path` and `math` are incredibly useful, as is the builtin
argparse.
paul
[1] https://fishshell.com/docs/current/commands.html#tools
[2] https://github.com/sharkdp/fd
--
√ https://wurzel.org
❤ https://neo-layout.org
❤ https://useplaintext.email
❤ YYYY-MM-DD (ISO 8601/RFC 3339)
� UTF-8
☠ please don't TOFU! https://en.wikipedia.org/wiki/Posting_style
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users