Unix script help needed
Jul. 27th, 2009 11:02 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I have hit a brick wall and any help that can be offered would be gratefully appreciated. My Google-fu isn't up to the task, we have no reference books on Unix scripting here ("here's a card with basic Unix commands - have fun!"), my local library has no books on Unix scripting and I haven't got five days for Canada Post to lose deliver an Amazon order of books for me.
I'm attempting to loop through some files in a directory, count the number of files that contain a particular word sequence and put that count into a file that I can then email. All the filenames that I am searching begin with 'O'. So far, if I cd to the directory and put this into the command line it works:
My log file correct shows a count of 2.
When I do the same thing in my script and run it, I get big fat zeros in my report :-(
According to my log, I've cd'd to the correct directory. I've tried using $LOGDIR1/O* with no luck.
Can anyone point me to some resources that might help? If it helps, I would appear to be using the Korn shell in this installation of Unix. The mere fact that I've had to write "appear to be using" should tell you how much I actually know about Unix :-(
I'm attempting to loop through some files in a directory, count the number of files that contain a particular word sequence and put that count into a file that I can then email. All the filenames that I am searching begin with 'O'. So far, if I cd to the directory and put this into the command line it works:
print cat O* | grep -c 'XXXX_PROD' >> test.log
My log file correct shows a count of 2.
When I do the same thing in my script and run it, I get big fat zeros in my report :-(
cd $LOGDIR1
print $PWD >> $REP
print "Count of XXXX_PROD jobs run (test only):" >> $REP
print cat O* | grep -c 'XXXX_PROD' >> $REP
According to my log, I've cd'd to the correct directory. I've tried using $LOGDIR1/O* with no luck.
Can anyone point me to some resources that might help? If it helps, I would appear to be using the Korn shell in this installation of Unix. The mere fact that I've had to write "appear to be using" should tell you how much I actually know about Unix :-(
no subject
Date: 2009-07-27 03:12 pm (UTC)This really isn't my thing. And my boss cheerfully expects me to have the entire script tested and ready to go by end of play today. Um, I think not, somehow.
no subject
Date: 2009-07-27 03:22 pm (UTC)Let me see who's in along the way, I'm sure my neighbour Dave will know and he was in earlier... Back soonish!
no subject
Date: 2009-07-27 04:36 pm (UTC)no subject
Date: 2009-07-27 08:49 pm (UTC)