Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Here is the output from qacct -o

Total : OWNER WALLCLOCK UTIME STIME CPU MEMORY IO IOW         ========================================================================================================================= 
Total : adeluca 1947 45.550 8.325 53.875 3.079 17.268 0.000 
Total : athardin 1 0.039 0.056 0.095 0.000 0.000 0.000 
Total : axelsone 35398815 34902115.362 37631.812 34939747.173 33441742.534 11432.294 0.000 
Total : bfinley 1875 6654.039 108.112 6762.151 2867.369 33.136 0.000 
Total : bihe 12018070 6479035.116 1168497.282 7647532.398 4463769.624 478955.800 0.000 
Total : brogers 108710282 108181275.073 46824.068 108228099.141 1741423.539 2.129 0.000 
Total : ckbui 10 0.006 0.006 0.012 0.000 0.000 0.000 
Total : ctokheim 114192 15177.837 460.056 15898.657 11150.583 208.076 0.000 
Total : dliang 6483476 8023175.362 80187.624 13133457.012 12167904.607 472.620 0.000 
Total : gaolong 3395364 3382687.178 5792.021 3388479.200 6904718.986 11.328 0.000 
Total : htrn 1 0.016 0.006 0.022 0.000 0.000 0.000 

Right now I have

qacct - o | awk 'NR>2 print {$1}'

The purpose of this is to pull the individual user names like so:

adeluca
athardin
axelsone
bfinley
bihe
brogers
ckbui
ctokheim
dliang
gaolong
htrn

What I want is to be able to parse through the list and for each user be able to pull out each individual user to put into another file that requires their username.

For Example.

~/qacct.monthly adeluca

So What I want ultimately is to be able to parse through qacct -o, get the individual users and be able to call something like

~/qacct.monthly $users

So that I don't have to manually put the individual users in every time.

share|improve this question
2  
Please add some sample output from qacct - o so we can see what the input to awk is. –  Mikel Apr 4 '12 at 17:39
    
Anyway, print out of {} seems rather strange. –  enzotib Apr 4 '12 at 17:41
1  
I'm not sure what you actually mean, but what you have should be NR>2 { print $1 } –  Kevin Apr 4 '12 at 17:49
1  
I'm a little confused as to what "print each individual name" means. With these kinds of questions it helps if you include the complete output from the command (qacct - o) and what exactly you want the processed output to be –  Michael Mrozek Apr 4 '12 at 17:50

1 Answer 1

up vote 2 down vote accepted
for i in `qacct - o | awk 'NR>2 print {$1}'`
do
  ~/qacct.monthly $i
done
share|improve this answer
    
This is definitely how I would do it. –  Chris Apr 5 '12 at 18:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.