Do you require that the header is EXACTLY like the one you posted? In this case, there is nothing CSV-specific in your question. Instead, the problem boils down to finding out, whether the first line of a file has a certain content.
Or do you require that the header is STRUCTURALLY like the one you posted? For example, the CSV-file format allows fields to be quoted; or, you might consider trailing spaces after the header names insignificant; or you might allow the fields to occur in any order. In this case, you need to specify, what exactly are the conditions to regard the header valid.
cd $MOUNT_DIR
for file in $(ls ${MOUNT_DIR}/Test*.txt)
do
file_name=$(basename $file)
echo $name
chmod -R 777 $MOUNT_DIR$name
match_header=awk NR==1 $file_name
echo "the header file from the input file is" $match_header
if [ comm $match_header =] ** not able the script how to compare the header columns to mentioned columns **
then
echo $name:"Header file mismatch, terminate the flow " >> $JOB_LOG
exit 1
else
echo $name:"Header file match, We can process this file " >> $JOB_LOG
fi
done
---------- Post updated at 02:09 AM ---------- Previous update was at 01:58 AM ----------
rovf, Sorry for confusion. it was txt file (I have edited the post).
What do you mean by "matching". Being literally equal? Or are you thinking of some kind of pattern matching?
Also, specify which shell you want the script to run in. This might be an important point if you are looking for some kind of pattern matching instead of just testing equality (which is trivial).