2

Currently I have

if [[ $INPUT_FILE == *".aac" ]] || [[ $INPUT_FILE == *".aiff" ]] || [[ $INPUT_FILE == *".pcm" ]]

I have tried the following, which does not work. It does not match anything.

if [[ $INPUT_FILE == *".aac" || *".aiff" || *".pcm" ]]

Is there any way to factor this expression?

2
  • @RenaudPacalet well I mean it doesn't work. I was just trying to give the idea of what i was looking for Commented Nov 18, 2021 at 15:30
  • @RenaudPacalet thanks for the recommendation! will do that Commented Nov 18, 2021 at 15:39

1 Answer 1

6

With [[ you could use a regex (specifically, an Extended Regular Expression)

if [[ $input_file =~ \.(aac|aiff|pcm)$ ]]; then
  : something
fi

or an extglob

if [[ $input_file = *.@(aac|aiff|pcm) ]]; then
  : something
fi

Or you may use a case statement

case $input_file in
 *.aac | *.aiff | *.pcm )
   # anything
 ;;
esac
Sign up to request clarification or add additional context in comments.

1 Comment

"extglob" patterns are documented in 3.5.8.1 Pattern Matching

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.