Totally agreed. I'm being misunderstood, this is definitely not about the
filter this is just about matching the multiple columns. I should have
mentioned that in my post!
Rajan
"Ed Morton" <morton@[EMAIL PROTECTED]
> wrote in message
news:47E6D0B5.4010608@[EMAIL PROTECTED]
> On 3/23/2008 4:04 PM, Rajan wrote:
>
> [please don't top-post, fixed below]
>
>> "spacegoose" <spacegoose@[EMAIL PROTECTED]
> wrote in message
>>
news:8acca503-5eaf-4d95-abca-c8fd6390f99c@[EMAIL PROTECTED]
>>
>>>i have a program that prints out a formatted df command
>>>by sorting and grepping and using awk to print it out.
>>>
>>>it basically executes df -h | grep whatever | sort -n +5 and then
>>>awks
>>>to a nice printout like:
>>>
>>>disk size capacity
>>>------------------
>>>foo 20gb 70%
>>>moo 40gb 25%
>>>bar 20gb 70%
>>>
>>>i'd like to add a new column "accounts" to this print out.
>>>
>>>the no. of accounts is derived from a command:
>>>awk {'print $5'} myFile |sort |uniq -c |sort -nr
>>>
>>>which prints rows like:
>>>
>>>450 foo
>>>300 moo
>>>104 bar
>>>
>>>i want to integrate this command into the formatted df program's
>>>output.
>>>i can't figure out how to appropriately append the "account count"
>>>column from the myFile command, to the appropriate row of the
>>>formatted df output,
>>>e.g. where col 1 from the formatted df output matches col 2 of the
>>>myFile command.
>>>
>>>so it looks like this:
>>>
>>>
>>>disk size capacity accounts
>>>---------------------------
>>>foo 20gb 70% 450
>>>moo 40gb 25% 300
>>>bar 20gb 70% 104
>>>
>>>
>>>Thanks for any hints!
>>>sg
>>
>> you can do this with a combination of sort and paste but if you are a
>> gawky
>> like me
>>
>> BEGIN{
>> cmd="df -h | grep whatever | sort -n +5"
>> while(cmd | getline)
>> { mntspace[$1]=$2;mntused[$1]=$3}
>> cmd="awk {'print $5'} myFile |sort |uniq -c |sort -nr"
>> while(cmd|getline)
>> {mntacs[$2]=$1}
>> printf "%-12s %-12s %-12s %-12s", "Disk", "Space", "Used", "Accounts"
>> for (each1 in mntspace) {printf "%-12s %-12s %-12s %-12s", each1,
>> mntspace[each1], mntused[each1], mntacs[each1]}
>> exit
>> }
>>
>
> I don't mean to be rude, but the above is missing the point of awk as a
> text-processing tool and trying to force it to behave like a shell, i.e.
> an
> environment for invoking tools. It's totally the wrong approach to
solving
> this
> or any other problem.
>
> Ed.
>
>


|