Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: matching co...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 26 of 26 Topic 2199 of 2236
Post > Topic >>

Re: matching column variables from two awks!

by Ed Morton <morton@[EMAIL PROTECTED] > Mar 26, 2008 at 08:13 AM

On 3/24/2008 10:55 AM, spacegoose wrote:
> On Mar 23, 1:41 am, Ed Morton <mor...@[EMAIL PROTECTED]
> wrote:
> 
>>On 3/23/2008 12:13 AM, spacegoose wrote:
>><snip>
>>
>>>That did it. Thanks. One last thing: Can this be combined into one
>>>file to act on myFile:
>>>so that everything is contained in one file (with a reference to
>>>myFile inside)?
>>
>>I think what you want is to put this in a file:
>>
>>------------
>>df -h | sort +5 | awk '
>>BEGIN {
>>printf "%-15s%12s%10s%10s%10s%10s\n", "File System", "bytes", "used",
"avail",
>>"capacity", "accounts"
>>print
"-------------------------------------------------------------------"}
>>
>>NR==FNR{ accts["/local/ds/"$5]++; next }
>>/dsk/ { printf "%-15s%12s%10s%10s%10s%10s\n", $6, $2, $3, $4, $5,
accts[$6]+0 }
>>' myFile -
>>-------------
>>
>>Regards,
>>
>>        Ed.
> 
> 
> This is working, Thanks Ed.
> Can you make the columns tally at the bottom?

df -h | sort +5 | awk '
BEGIN {
printf "%-15s%12s%10s%10s%10s%10s\n", "File System", "bytes", "used",
"avail",
"capacity", "accounts"
print
"-------------------------------------------------------------------"
}
NR==FNR{ accts["/local/ds/"$5]++; next }
/dsk/ {
	printf "%-15s%12s%10s%10s%10s%10s\n", $6, $2, $3, $4, $5, accts[$6]+0
	tot["bytes"]+=$2
	tot["used"]+=$3
	tot["avail"]+=$4
	tot["capacity"]+=$5
	tot["accounts"]+=accts[$6]
}
END {
	printf "%-15s%12s%10s%10s%10s%10s\n", "Totals", tot["bytes"],
tot["used"],
tot["avail"], tot["capacity"], tot["accounts"]
}
' myFile -




 26 Posts in Topic:
matching column variables from two awks!
spacegoose <spacegoose  2008-03-20 21:36:28 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-21 00:04:37 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 07:15:57 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-21 09:40:47 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 09:33:56 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-21 14:59:28 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 13:51:43 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-21 16:16:40 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 14:00:13 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 15:03:17 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 16:09:17 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-21 18:32:47 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-21 22:00:21 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-22 07:37:33 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-22 07:37:12 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-22 18:16:25 
Re: matching column variables from two awks!
gazelle@[EMAIL PROTECTED]  2008-03-22 23:23:43 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-22 19:44:09 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-22 22:13:30 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-23 00:41:29 
Re: matching column variables from two awks!
"Rajan" <svr  2008-03-23 17:04:58 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-23 16:50:45 
Re: matching column variables from two awks!
gazelle@[EMAIL PROTECTED]  2008-03-23 22:19:40 
Re: matching column variables from two awks!
"Rajan" <svr  2008-03-23 20:58:50 
Re: matching column variables from two awks!
spacegoose <spacegoose  2008-03-24 08:55:09 
Re: matching column variables from two awks!
Ed Morton <morton@[EMA  2008-03-26 08:13:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 6:37:31 CDT 2008.