[GRLUG] Bash glob

L. V. Lammert lvl at omnitec.net
Tue May 7 12:16:29 EDT 2013


Trying to ensure the parameter to a script matches:

	YYYY-MM (e.g. 2013-06)

It would seem this would be the desired pattern:

if [[ ! $1 =~ '[0-9]{4}-[0-9]{2}' ]] ; then
   echo '    Usage: backup YYYY-MM'
   exit
fi

However it will not match a valid YYYY-MM. Cluestick, anyone?

	Thanks!

	Lee


More information about the grlug mailing list