1

For example I have files that have names like

  • book1_volume1.txt
  • book1_volume2.txt
  • book1_review.txt
  • book2_volume1.txt

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

2
  • 2
    The simplest wait to do so is to use wildcards, specifically book[0-9]_volume* matches Commented Sep 15, 2017 at 14:29
  • Man, this was really simple! Thank you. Can you make an answer so I could mark it as the right one? Commented Sep 15, 2017 at 14:35

2 Answers 2

2

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

shopt -s extglob nullglob
books=( book_+([0-9])_volume* )
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.