How to check file name format through shell script?
I had written a shell script that accepts input file as cmd line argument and process this file.
if [ $# -eq 1 ]; then
if [ -f $1 ]; then
error "$ERROR_CODE : Input file $1 is not available";
echo "usage : $usage";
I want a help in writting a get_input_file function which checks for file name format.
My input file name format is MIG_CR_<TYPE>_<TIMESTAMP>.<EXT>
FILE = '$1'
#checking file exist or not
if [ ! -f $FILE ]; then
echo "$FILE : does not exists"
elif [ ! -r $FILE ]; then
echo "$FILE: can not read"
// TO do
// check file name format is correct or not
Can anyone tell me how can I check the format of file name?
Please help me out. Thanks in advance. :o