![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| while loop inside while loop | panknil | Shell Programming and Scripting | 0 | 01-07-2008 12:49 PM |
| while loop | smoorthy | Shell Programming and Scripting | 3 | 09-20-2007 06:28 AM |
| while loop | whited05 | Shell Programming and Scripting | 2 | 11-03-2005 12:27 PM |
| for loop? | surjyap | Shell Programming and Scripting | 1 | 10-20-2005 08:52 AM |
| how to get the similar function in while loop or for loop | trynew | Shell Programming and Scripting | 3 | 06-17-2002 12:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Do ... Loop
ill be the first to admit i am a bit of a bash scripting noob... but ive come againest a small problem...
LOG=/var/log/local2.log for i in SEC-0 SEC-1 SEC-2 SEC-3 SEC-4 SEC-5 SEC-6 SEC-7 do grep $i $LOG | wc -l done The above works and gives me 8 different values. Later on in the script I wish to echo these strings, so i would like them as varibles. Is there anyway to assign each total against a varible so when this is finished I have... something like.. $SEC-0=some number $SEC-1=some number ..... etc etc I hope I have made this clear, thanks in advanced.... |
|
||||
|
Ive now found what I was looking for ... Code:
LOG="/var/log/local
level=(Emergency Alert Critical Error Warning Notification Informational Debugging)
for i in 0 1 2 3 4 5 6 7
do
printf "${level[$i]} - " ; grep -c SEC-$i $LOG
done
But the only thing im unsure of is how to allow for the wildcard in for the $LOG variable ???? edit by bakunin: please use "code"-tags when you post program code. Thx. Last edited by bakunin; 08-06-2008 at 12:09 AM.. |
|
|||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|