
下記の文字列がいくつかあります
- 2-0 854 0/413/5963 W 65.19 0 0 0.0 4.76 115.86
::1 www.example.com GET /server-status HTTP/1.1 - 2-0 854 0/413/5963 W 65.19 0 0 0.0 4.76 115.86
::1 www.example.com GET /server-status HTTP/1.1
そして、以下のような出力が欲しいです:-
サーバーステータス HTTP
サーバーステータス HTTP
答え1
試す
awk
.... | awk -F/ '{print $4}'
どこ
-F/
区切りとして使うprint $4
4番目のフィールド
グレップ
grep -o "[^/]*HTTP"
どこ
-o
一致した文字列のみ[^/]*HTTP
/
HTTPが後に続かない任意の文字
答え2
これを試して
awk -F/ '/GET/{print $2}' input.txt