在grep的使用范围 [英] Using range in grep

查看:120
本文介绍了在grep的使用范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的命令不会正常工作。

 的grep -B3'MAX_VALUE:127。PROC _ *

但我需要比较最大值的数目和发现,如果它是127和200之间

 的grep -B3。MAX_VALUE:(大于127和< 200)'PROC _ *


解决方案

 的grep'MAX_VALUE:'PROC _ * | awk的'$ 2〜/ [0-9] {3} $ /&放大器;&安培; $ 2  - ; 127安培;&安培; $ 2'; 200'

编辑:增加检查(3位数字)$

The following command does work as expected.

grep -B3 'Max_value: 127' proc_*.*

But I need to compare the number of Max Value and find if it is between 127 and 200.

grep -B3 'Max_value: (>127 and <200)' proc_*.*

解决方案

grep 'Max_value:' proc_*.* | awk ' $2 ~ /[0-9]{3}$/ && $2 > 127 && $2 < 200 '

edit: adding check for (3 digit numeric)$.

这篇关于在grep的使用范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆