Running on OS X with a bash script:
sourceFile=`basename $1`
shopt -s nocasematch
if [[ "$sourceFile" =~ "adUsers.txt" ]]; then echo success ; else echo fail ; fi
The above works, but what if the user sources a file called adUsers_new.txt
?
I tried:
if [[ "$sourceFile" =~ "adUsers*.txt" ]]; then echo success ; else echo fail ; fi
But the wildcard doesn't work in this case.
I'm writing this script to allow for the user to have different iterations of the source file name, which must begin with aduser
and have the .txt
file extension.