4

使用率が 70% を超えるすべての結果を grep したい

出力例:

{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":69,"dir":"/root"},
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":79,"dir":"/oracle"},
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":1,"dir":"/oradump"},
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":90,"dir":"/archive"},

grep 後の予想ビュー:

{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":79,"dir":"/oracle"},
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":90,"dir":"/archive"},
4

4 に答える 4

7

ここでは awk の方が適しています。

$ awk -F'[:,]' '$6>70' file
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":79,"dir":"/oracle"},
{"ipaddr":"1.1.1.1","hostname":"host1.test.com","percentage":90,"dir":"/archive"},
于 2013-05-31T12:15:46.747 に答える
3
perl -F'[:,]' -ane 'print if $F[5]>70' file
于 2013-05-31T12:27:39.110 に答える
0

GNU シード

sed -n '/:[0]\?70,/d;/:[0-1]\?[7-9][0-9],/p' file
于 2013-06-01T22:47:37.307 に答える