![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| extracting data from files.. | anchal_khare | Shell Programming and Scripting | 1 | 04-03-2008 07:56 AM |
| Problem in extracting vector data | ahjiefreak | Shell Programming and Scripting | 2 | 03-18-2008 06:09 AM |
| Extracting Data from a File | oop | UNIX for Dummies Questions & Answers | 0 | 07-31-2007 12:48 PM |
| Using loop reading a file,retrieving data from data base. | Sonu4lov | Shell Programming and Scripting | 1 | 01-19-2007 03:38 AM |
| Extracting Data From Sendmail | calex | Shell Programming and Scripting | 3 | 01-15-2007 08:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
The users.dat file serves no useful purpose and it is leading you into a double loop. Try this... Code:
#! /usr/bin/ksh
firsttime=1
sort mailuse.dat | while read user count date ; do
if ((firsttime)) ; then
firsttime=0
olduser=$user
sum=0
fi
if [[ $user != $olduser ]] ; then
echo $olduser $sum
olduser=$user
sum=0
fi
((sum=sum+count))
done
echo $olduser $sum
exit 0
|
|
|||||
|
Perderabo, Thanks a million! Your script is fast, it doesn't grep each name in the user.dat thingy. I also tried this thing, thought I would just paste it. (I do realize that this is very bad programming and slow too!) Code:
#!/bin/sh
rm /tmp/mails.log # remove old logs
for i in `cat walusers.dat | awk '{print $1}'`
do
total=0;
echo $i; # shows which users have gone by!!
for j in `grep $i maildeli.final | awk '{print $2}'`
do
echo $j;
total=$total+$j;
done;
echo $i " " $total >>/tmp/mails.log;
done
After using Perderabo's script, I decided to join the script output with users.dat. That gave me a a list of "power mail users". ----- join -a 1 -o Nomails -e 1.1 2.2 user.dat mails.log >usage.list ----- Thanks again! ![]() added code tags for readability --oombera Last edited by oombera; 02-20-2004 at 12:39 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|