Hi,
I want to find some files and then search for some lines in it with a particular pattern and then write those lines into a file. To do this I am using something like this from command prompt directly.
cd /mdat/BVG
find -name "stmt.*cl" -newer temp.txt | xargs -i awk '/BVG-/{print}' {} > /home/sandhya/list.txt
#awk -f BVG-stmt.awk /home/sandhya/list.txt > /home/sandhya/BVG-Statement-detail.txt
This works absolutely fine. But I have lots of directories in mdat and I have to do the same action in all of it. So I decided to write a shell script so that it works for all. Below is the shell script code for it. But the problem is that when I execute the above commands from shell script, I do not get the desired output. Can anybody help me out?
*****************************************************
Shell Script
*****************************************************
DESTDIR=/home/sandhya
CLIENT_NAME=
while [ -z "${CLIENT_NAME}" ]
do
echo "Enter Client Short Name :(<Ctrl>-C, <Enter> to cancel): \c"
read CLIENT_NAME
done
CLIENT_NAME=`echo $CLIENT_NAME | tr '[:lower:]' '[:upper:]'`
if [ -d /mdat/${CLIENT_NAME} ]
then
echo "Client is valid!!"
else
echo "\n Client ${CLIENT_NAME} does not exist. Try again!!\n"
exit 1
fi
cd /mdat/${CLIENT_NAME}
LNAME=${DESTDIR}/list.txt
#SDNAME=${DESTDIR}/${CLIENT_NAME}-Statement-detail.txt
#AWKF=${CLIENT_NAME}-stmt.awk
find -name "stmt.*cl" -newer temp.txt | xargs -i awk '/${CLIENT_NAME}-/{print}' {} > ${LNAME}
#awk -f ${AWKF} ${LNAME} > ${SDNAME}
*********************************************************
Note: The contents of awk file is same only difference is the pattern BVG replaced with other appropriate client names/dirs.
OS: QNX 4.25
Thanks in advance for your help.
Sandhya.