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 -


|