Suppose I have a filename in a variable.
FILENAME_VAR = "1000-Feature.mp4"
What is the bash command I can use to test that the filename in the variable $FILENAME_VAR
contains the word Feature
?
Suppose I have a filename in a variable.
FILENAME_VAR = "1000-Feature.mp4"
What is the bash command I can use to test that the filename in the variable $FILENAME_VAR
contains the word Feature
?
One way to do it
if [[ $FILENAME_VAR =~ Feature ]]
then
echo good
else
echo bad
fi
$ [[ $FILENAME_VAR = *Feature* ]] ; echo $?
0
$ [[ $FILENAME_VAR = *Feature2* ]] ; echo $?
1