I am attempting to compare wc -l in multiple files to validate todays wc -l is greater than yesterdays. Here is what I was experimenting with:
#!/bin/ksh
---------------
# Compare the record count file by file to make sure we did not receive less
---------------#
if [[ -a /u07/scripts/record_counts ]]
then
cat /dev/null > /u07/scripts/record_counts
else
touch /u07/scripts/record_counts
fi
for currentFile in /u14/tempdata/staging/*.in
do
wc -l $currentFile >> /u07/scripts/record_counts
done
sed 's/\/u14\/tempdata\/staging\///' < /u07/scripts/record_counts > /u07/scripts/pre_record_counts
cat /dev/null > /u07/scripts/record_counts
for currentFile in /u14/tempdata/staging_bkp/*.in
do
wc -l $currentFile >> /u07/scripts/record_counts
done
sed 's/\/u14\/tempdata\/staging\///' < /u07/scripts/record_counts > /u07/scripts/post_record_counts
for SAPfile in `cut -f 2 -d ' ' post_record_counts`
do
preCNT=`awk '/$SAPfile/' pre_record_counts|cut -f 1 -d ' '`;export preFile
postCNT=`awk '/$SAPfile/' post_record_counts|cut -f 1 -d ' '`;export postFile
if (($preCNT < $postCNT))
then
echo Danger Will Robinson, $SAPfile pre $preFile vs post $postFile
else
echo GOOD $SAPfile
fi
done
------
I am getting the following error:
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1. The file is pre_record_counts.
The source line number is 1.
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1. The file is post_record_counts.
The source line number is 1.
ksh[5]: < : syntax error
GOOD zmm01.in
#!/bin/ksh
---------------
# Compare the record count file by file to make sure we did not receive less
---------------#
if [[ -a /u07/scripts/record_counts ]]
then
cat /dev/null > /u07/scripts/record_counts
else
touch /u07/scripts/record_counts
fi
for currentFile in /u14/tempdata/staging/*.in
do
wc -l $currentFile >> /u07/scripts/record_counts
done
sed 's/\/u14\/tempdata\/staging\///' < /u07/scripts/record_counts > /u07/scripts/pre_record_counts
cat /dev/null > /u07/scripts/record_counts
for currentFile in /u14/tempdata/staging_bkp/*.in
do
wc -l $currentFile >> /u07/scripts/record_counts
done
sed 's/\/u14\/tempdata\/staging\///' < /u07/scripts/record_counts > /u07/scripts/post_record_counts
for SAPfile in `cut -f 2 -d ' ' post_record_counts`
do
preCNT=`awk '/$SAPfile/' pre_record_counts|cut -f 1 -d ' '`;export preFile
postCNT=`awk '/$SAPfile/' post_record_counts|cut -f 1 -d ' '`;export postFile
if (($preCNT < $postCNT))
then
echo Danger Will Robinson, $SAPfile pre $preFile vs post $postFile
else
echo GOOD $SAPfile
fi
done
------
I am getting the following error:
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1. The file is pre_record_counts.
The source line number is 1.
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1. The file is post_record_counts.
The source line number is 1.
ksh[5]: < : syntax error
GOOD zmm01.in