入力ファイルごとに出力ファイルを切り替える
/SERVER/ { close(f); f = ""; next } !f && !NF { next } !f { split($0, a, ".") f = a[2] ".vol" ext next } { print >f }
というファイルを使って、
$ awk -v ext=22 -f syscfg6.awk file01
とし、出力ファイルを切り替えたいようです。
ファイルは以下のようなものです。
SERVER home.serv0011.com Aggregate aggr0 (online, raid_dp) (block checksums) Plex /aggr0/plex0 (online, normal, active) RAID group /aggr0/plex0/rg0 (normal) RAID Disk Device HA SHELF BAY CHAN Pool Type RPM Used (MB/blks) Phys (MB/blks) --------- ------ ------------- ---- ---- ---- ------------------- -------------- dparity 0b.16 0b 1 0 FC:B - FCAL 10000136000/278528000 137422/281442144 parity 0b.18 0b 1 2 FC:B - FCAL 10000136000/278528000 137422/281442144 data 0b.20 0b 1 4 FC:B - FCAL 10000136000/278528000 137422/281442144 data 0b.22 0b 1 6 FC:B - FCAL 10000136000/278528000 137422/281442144 data 0b.24 0b 1 8 FC:B - FCAL 10000136000/278528000 137422/281442144 data 0b.26 0b 1 10 FC:B - FCAL 10000136000/278528000 137422/281442144 Spare disks RAID Disk Device HA SHELF BAY CHAN Pool Type RPM Used (MB/blks) Phys (MB/blks) --------- ------ ------------- ---- ---- ---- ------------------- -------------- Spare disks for block or zoned checksum traditional volumes or aggregates spare 0b.28 0b 1 12 FC:B - FCAL 10000136000/278528000 137422/281442144 Partner disks RAID Disk Device HA SHELF BAY CHAN Pool Type RPM Used (MB/blks) Phys (MB/blks) --------- ------ ------------- ---- ---- ---- ------------------- -------------- partner 0b.33 0b 2 1 FC:B - ATA 72000/0 423889/868126304 partner 0b.45 0b 2 13 FC:B - ATA 72000/0 423889/868126304 partner 0b.38 0b 2 6 FC:B - ATA 72000/0 423889/868126304 partner 0b.52 0b 3 4 FC:B - ATA 72000/0 423889/868126304 partner 0b.36 0b 2 4 FC:B - ATA 72000/0 423889/868126304
Answer
結局以下のような回答がありましたが、要点を得ない出題でした。
/SERVER/ { if (f) printf "%-10s %6d %12.1f\n", "total", ND, n(MB) > f close(f); f = ""; next } !f && !NF { next } !f { split($0, a, ".") f = a[2] ".vol" ext printf "%-10s %-6s %-12s\n", "KIND", "#DISKS", "STORAGE (TB)" > f ND = MB = 0 next } /^Aggregate aggr[0-9]/ { kind = $2; next } /^Spare disks/ { kind = "spare"; next } /^Partner disks/ { kind = "partner"; next } /^-----/ && kind { working = 1; next } working && /[0-9]/ && NF { ++nd; mb += $NF; next } working && !NF { printf "%-10s %6d %12.1f\n", kind, nd, n(mb) > f ND += nd; MB += mb kind = ""; nd = mb = 0 working = 0 } END { if (working) { printf "%-10s %6d %12.1f\n", kind, nd, n(mb) > f ND += nd; MB += mb } if (f) printf "%-10s %6d %12.1f\n", "total", ND, n(MB) > f } function n(a) { return a / (1024 * 1024) }