Hi all. I'm creating a script that will search for whatever criteria you want to enter and then display the information. The problem is, I'm not sure how to grep for different directories, or different file names. Some of the file names that I'm looking at are in /dso/eis/log/batlog.log.20030701, or hislog.20030701, and there are also older files that are moved to a different directory /dso/eis/log/backup/batlog.log.20030701. My script looks like this:
# /bin/ksh!
echo "\tPlease enter the battery number you wish to search for...\c"
read ans
if [[ $ans != 0 ]]
then
cat /dso/eis/log/batlog.log.* | grep $ans > /dso/eis/log/battsearch.log
awk -F, 'BEGIN { print "LRT DATE TIME OLD BATT NAME DEPT IN/OUT NEW BATT STATUS"
print "--- ---- ---- -------- ---- ---- ------ -------- ------"}
{ printf "%-7s %-8s %-8s %-12s %-16s %-13s %-10s %-12s %-8s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9 }' /dso/eis/log/batt
search.log
else
exit
fi
print ""
print ""
print ""
echo "\tWould you like to print this? (y/n)"
read ans1
if [ $ans1 = "y" -o $ans1 = "Y" ]
then
lp -dps@pr7 /dso/eis/log/battsearch.log
else
exit
fi
Can someone explain? Up where I'm doing the cat on the file is where the problem lies. Thanks.
# /bin/ksh!
echo "\tPlease enter the battery number you wish to search for...\c"
read ans
if [[ $ans != 0 ]]
then
cat /dso/eis/log/batlog.log.* | grep $ans > /dso/eis/log/battsearch.log
awk -F, 'BEGIN { print "LRT DATE TIME OLD BATT NAME DEPT IN/OUT NEW BATT STATUS"
print "--- ---- ---- -------- ---- ---- ------ -------- ------"}
{ printf "%-7s %-8s %-8s %-12s %-16s %-13s %-10s %-12s %-8s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9 }' /dso/eis/log/batt
search.log
else
exit
fi
print ""
print ""
print ""
echo "\tWould you like to print this? (y/n)"
read ans1
if [ $ans1 = "y" -o $ans1 = "Y" ]
then
lp -dps@pr7 /dso/eis/log/battsearch.log
else
exit
fi
Can someone explain? Up where I'm doing the cat on the file is where the problem lies. Thanks.