S
S
Sergey Burduzha2017-11-30 23:33:50
bash
Sergey Burduzha, 2017-11-30 23:33:50

How to enable regular expressions in zsh?

This expression ls +([0-9]).jpgdoesn't work in zsh, but it does in bash.
How to enable regex support in zsh?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2017-12-01
@serii81

ls [0-9].jpg
The syntax of zsc is not always the same as bash.

J
jcmvbkbc, 2017-12-01
@jcmvbkbc

The expression ls +([0-9]).jpg doesn't work in zsh, but it does in bash.

It does not work in bash, at least in default settings:
$ ls +([0-9]).jpg
bash: syntax error near unexpected token `('

Bash does not support regular expressions, it has extended globbing:
If the extglob shell option is enabled using the shopt builtin, several extended pattern matching operators are recognized.

S
Saboteur, 2017-12-01
@saboteur_kiev

These are not regular expressions, these are file masks - bash supports *, ?, ~ and a simple list with ranges in square brackets []
But this is NOT a regular expression, it does not fall under any regexp standard. There are no such quantifiers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question