I have a file "fwcsales_filenames.txt" which has a list of file names that are supposed to be copied to another directory. In addition to that, I am trying to extract the date part and write to the log.
I am getting the regular expression error when trying to strip the date part using the "ll" command. But I was able to count the number of records for each filename inside the list.
Please let me know what mistake I am doing here while usine AWK to print the date part.
while read FILENAME
do
cp ${FTP}/$FILENAME ${EXPORT}/nz.$FILENAME
if [ $? -eq 0 ]
then
let NUM_COPIED=`expr $NUM_COPIED+1`
DAY=$(ll $FTP | awk '/$FILENAME/ {print $6 $7 substr($8,1,5)}' )
echo "*** FTP file from $DAY "
RECORDS=$(cat $FTP/$FILENAME |wc -l )
echo '*** Number of $FILENAME records = ' $RECORDS
fi
done < ${FTP}/fwcsales_filenames.txt
Output:
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1.
The source line number is 1.
*** FTP file from
*** Number of $FILENAME records = 256