Hi All,
I have a script that looks for a file. Then changes the name of the file and then scp's it to another server. The problem is this was set up for one file to be in the directory. Now there is going to be another file with the same name but different information in it. I need to add a way to check inside the file and look on the first line of the file for a sequence of numbers(ex. 123456789). If that file has the sequence of numbers then finish the rest of the script.If it does not match the sequence then exit the script. My existing script is below.
#!/bin/sh -x
pospay=/usr/pa/archive/bw/bin_wsobserve/pospay
archive=/usr/pa/archive/bw/bin_wsobserve/pospay/archive
dest=/usr/pa/archive/bw/bin_wsobserve/pospay/wsobserve
sent=/usr/pa/archive/bw/bin_wsobserve/pospay/wsobserve/sent
cd "$pospay"
#CHECK IF THERE ARE ANY POSITIVE PAY FILES
if [ `find . -type f -maxdepth 1 -name "1455*" | wc -l` -eq 0 ]; then
echo "Exit NO FILES"
exit
else
gunzip 1455*
for file in 1455*
do
#this copies the file to new directory and removes everything after the -
cp "$file" "$dest/${file%%-*}"
gzip 1455*
mv "$pospay"/*.gz "$archive"
cd "$dest"
scp 1455*
abcd@xfer.abcd.com:/usr/pa/warner/wbdumpdir/bin_wsobserve
gzip "$dest"/1455*
mv "$dest"/1455* "$sent"
slogin
abcd@xfer.abcd.com "cd /usr/pa/warner/wbdumpdir/bin_wsobserve" "touch cur_dump.wsobserve;echo "1455"* >> cur_dump.wsobserve
;/usr/local/bin/bwconcord_send_wsobserve"
done
fi
Thanks,
Nazs