Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Help! need a script
Name: Naseem Rahman Date: November 8, 2000 at 11:56:40 Pacific
Comment:
I am trying to write a script that will take a log file as an input and search for a word and count the number of times it occur. Please Help
Name: Robert Smith Date: November 10, 2000 at 12:53:12 Pacific
Reply:
#!/usr/bin/sh ## ### #### ##### occur=`grep -c -i -e $1 $2` print "The Word $1 Appears $occur Times in $2" ## Remove the -i to make the search case sensitive. Parameter $1 is the word you are searching for, parameter to is the log file you want to search.
example "script" warning /var/adm/syslog/mail.log
Hope this helps!
Robert Smith Systems Administrator Biomatrix Inc.
0
Response Number 2
Name: naseem rahman Date: November 16, 2000 at 15:13:22 Pacific
Reply:
Robert thanks for your help. Just wondering If I want to search for a phrase do I just use "" ?
0
Response Number 3
Name: Mark Stanbrook Date: November 21, 2000 at 08:36:44 Pacific
Reply:
In general I tend to use double quotes to enclose phrases though in certain cases single quotes are preferred. The O'Reilly UNIX in a Nutshell book has a little section on this - second edition page 44.
You can do "Word word2" to search for: Word word2 'Word "word2"' to search for: Word "word2" "Word \"word2\"" also for: Word "word2" "`date +%Y`" to search for the current year ie 2000 (as of writing!) Mark
Summary: i need a script which shd run for infinate loop and it should poll the current directory (excluding sub-directories)and whenevr a new *.txt comes, it shd call other script say temp.sh with this new *....
Summary: HI there, if anyone can help me it will be much appreciated. I need to make a bourne shell script which will ping a total of 30 servers to make sure they are alive and then print the records onto a f...
Summary: Hello gurus, I am just getting on the way with unix and i am new to shell scripting. i've already begun reading up on it. need some help. boss is rushing me to complete a script - i am struggling whe...