ファイル(1000行以上)があり、どの形式でも出力を取得する必要があります。各行に複数の行があることを確認する必要がありますthr
。以下の場合は3thr
つあり、5、4、2はそれぞれ各行の数ですthr
。
入力する:
19608250477[thr=22321]: Res90 at
1: 0x00007f1fb38d5089
2: 0x00007f1fb5565c79
3: 0x00007f1fbb097775
4: 0x00007f1fbb034a69
5: 0x00007f1fbb035467
19601889333[thr=19068]: Res87 at
1: 0x00007f1fc15f86c0
2: 0x00007f1fc1a27d7c
3: 0x00007f1fc1d0f312
4: 0x00007f1fc1caf054
16236545786[thr=55528]: Res67 at
1: 0x00007f1fb4959a90
2: 0x00007f1fb557ad94
以下の出力が必要です。
thr=22321 ; Count 5 # Count number of lines for each thr ; Each content will start with number (1: and finish with some numebr
thr=19068 ; Count 4
thr=55528 ; Count 2
ベストアンサー1
awk -F'[]=[]' '
function print_count() {
printf "thr=%d ; Count %d\n", key, count
}
$2 == "thr" {if (key) print_count(); key = $3; count = 0; next}
{count++}
END {print_count()}
' file
これは]
フィールド区切り記号=
として使用されます。[