I have a file(file name:NGC_DATA_(date)_(header).txt)
where (date) is in YYYYMMDD format and (header) is a integer with length 3
The content of first line of this file is
HDR(date)(header)
(date)&(header) is same as above.
I need to print message if it matches "file's" (date) and (header) with first line of that file (date) and (header) otherwise print message unsuccessful.
#!/bin/bash
FNAMESTUB=NGC_DATA
DATESTR=20110310
HEADER=111
FNAME="${FNAMESTUB}_${DATESTR}_${HEADER}.txt"
if [[ -f $FNAME ]]
then
FIRSTLINE=$(head -1 ${FNAME} )
if [[ "$FIRSTLINE" == "HDR${DATESTR}&${HEADER}" ]]
then
echo "Success"
else
echo "Header mismatch"
fi
else
echo "File not found"
fi