The processing directory contains the list of archive files and the file name command will retrieve the latest timestamp file and the below command does the egrep.
egrep 'CHECKS NOT BALANCED|
PAYMENTS ARE OUT OF BALANCE' filename
Problem:
I am not sure how to execute the fileName command in the processing directory and look for the egrep on the retrieved file.
When executed the egrep on the file, the command expects the file to be set to have the execute privilges, how can i set that during run time.
#!/bin/sh
processingDir="/usr/apps/irdc/informatica/spsf_sales/TgtFiles/ARCHIVE"
filename=`ls -1tr $processingDir/Check* | tail -1`
egrep 'CHECKS NOT BALANCED|PAYMENTS ARE OUT OF BALANCE' $filename
#!/bin/sh
processingDir="/usr/apps/irdc/informatica/spsf_sales/TgtFiles/ARCHIVE"
filename=$(ls -lrt $processingDir | awk '{a=$NF}END{print a}')
echo "Filename : ${filename}"
echo "Checking if ${filename} has read permission for the user. If not assign read permission"
[ -r ${filename} ] && echo "File ${filename} has read permission" || chmod 444 ${filename}
#Now do egrep
egrep 'CHECKS NOT BALANCED|PAYMENTS ARE OUT OF BALANCE' ${filename}
if you want to grep the today's file (only one file per day), then