Bobby
Bobby

Reputation: 584

How to use regex for numbers in the string?

For example I have files that have names like

How can I find all 'book%NUMBER%_volume' files in one search? How do I mask the number after 'book'?

Upvotes: 1

Views: 40

Answers (2)

glenn jackman
glenn jackman

Reputation: 246807

If there can be more than one digit, use an extended pattern:

shopt -s extglob nullglob
books=( book_+([0-9])_volume* )

Upvotes: 2

myaut
myaut

Reputation: 11504

The simplest way to do so is to use wildcards, specifically book[0-9]_volume* matches your example.

Upvotes: 1

Related Questions