![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| If then else loop not working | findprakash | UNIX for Dummies Questions & Answers | 2 | 05-24-2008 09:43 PM |
| For loop not working...! :( | bullz26 | Shell Programming and Scripting | 3 | 03-16-2008 03:28 AM |
| if loop is not working | ranga27 | Shell Programming and Scripting | 3 | 09-16-2007 09:19 AM |
| for loop not working - syntax error at line 6: `end of file' unexpected | debojyoty | Shell Programming and Scripting | 2 | 03-10-2006 12:45 PM |
| how to get the similar function in while loop or for loop | trynew | Shell Programming and Scripting | 3 | 06-17-2002 08:09 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Loop not working
Apologize if this is doesn't come under this group. I have a small script to find out users who last logged in to check there mail. (Tru 64 4.0, Netscape mail 3.6)
-----> cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u[s]++;las=substr($1)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list <----- It works when I run it with just one file (e.g script log20011107). But bombs out when I give command: script log*. It checks the first file only. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
You mention that you already tried looping it...
It didn't work when you did something like this?: for each in `ls -1 log*` do cat $each|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u[s]++;las=substr($1)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list done What happened when you tried that? |
|
#3
|
||||
|
||||
|
LivinFree,
This what I just did, and it worked: ---- cd /netscape/logsdir >/tmp/mailus.list cat Maillogs*|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/{s=$5;u[s]++;las=substr($1,1,8)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list join -a 1 -e NA -o 1.1 2.3 2.2 /tmp/users.list /tmp/mailusage.list>/tmp/totalusage.list ----- Initially, I did this and used to give me errors: can not open log-date-file. It would list all the files saying it can't open them for i in `ls /netscape/logsir/` cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/{s=$5;u[s]++;las=substr($1,1,8)} END {for (i in u) {print i,u[i],las}}'|sort>>/tmp/mailusage.list join -a 1 -e NA -o 1.1 2.3 2.2 /tmp/users.list ---- What did I do wrong then? Well thanks, Ciao Last edited by nitin; 11-08-2001 at 11:09 PM. |
||||
| Google The UNIX and Linux Forums |