Created
March 8, 2019 00:22
-
-
Save smallfield/3aae8fbf2b565694d7ddc5f3a831406a to your computer and use it in GitHub Desktop.
awkでsarの出力をパースして、項目毎のファイルに落とすやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!flag && NF > 1 && $1 != "平均値:" && FNR > 1{ | |
# 項目の最初の行。 | |
sub("/", "-", $2) | |
# ファイル名に使えるように/を取り除く | |
flag = $2 | |
} | |
$1 == "平均値:" { | |
#項目の最後ということなので、フラグをクリア | |
flag=0; | |
} | |
FNR == 1 { | |
flag=0; #出力フラグ初期化 | |
date=$4; #日付取得 | |
fn=$3; | |
OFS = "\t" | |
} | |
flag && NF > 0 { | |
$1=$1; #この行で何故か$0がタブ区切りで再構成される(!) | |
print date, $0 >> "out/"fn""flag".txt" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment