This is a good example of using regular expressions with JavaScript that I found on the internet.
POSIXExpressions-CharacterClasses
#!/bin/bash
#Make sure there are two arguments entered on the command line.
if [ $# -ne 2 ]
then
echo “Error in $0 – Invalid Argument Count”
echo “Error in $0 – Need two arguments”
echo “Example Syntax: $0 input_file output_file”
exit
fi
#Check if a file exists
if [ ! -f $infile ]
then
echo “Input file [$infile] not found – Aborting”
exit
fi
It’s possible to use even more complicated syntax with regular expressions:
I used this in my FTP script for safety surveillor.
case “$1? in
+(start|run) ) /usr/app/startup-script ;;
@([Ss])top ) /usr/app/stop-script ;;
esac?(pattern1 | pattern2 | … | patternn)
zero or one occurrence of any pattern*( pattern1 | pattern2 | … | patternn)
zero or more occurrences of any pattern@( pattern1 | pattern2 | … | patternn)
exactly one occurrence of any pattern+( pattern1 | pattern2 | … | patternn)
one or more occurrence of any pattern!( pattern1 | pattern2 | … | patternn)
all strings except those that match any pattern