grep -q
2015-12-07 15:17
127 查看
grep -q用于if逻辑判断
突然发现grep -q 用于if 逻辑判断很好用。
-q 参数,本意是 Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. 中文意思为,安静模式,不打印任何标准输出。如果有匹配的内容则立即返回状态值0。
小应用
# cat a.txt
nihao
nihaooo
hello
# if grep -q hello a.txt ; then echo yes;else echo no; fi
yes
# if grep -q word a.txt; then echo yes; else echo no; fi
no
突然发现grep -q 用于if 逻辑判断很好用。
-q 参数,本意是 Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. 中文意思为,安静模式,不打印任何标准输出。如果有匹配的内容则立即返回状态值0。
小应用
# cat a.txt
nihao
nihaooo
hello
# if grep -q hello a.txt ; then echo yes;else echo no; fi
yes
# if grep -q word a.txt; then echo yes; else echo no; fi
no
相关文章推荐
- JSONModel, Mantle
- 叽喳学习 随笔
- Add Binary
- BI使用者的角色
- [Linux主机] 优化你的php-fpm(php5.3+)让你的网站跑得更快
- Service和BroadCast配合使用
- Post请求相关整理
- set -x
- XML在Qt中的使用
- 堆维护
- 判别分析——逻辑斯蒂回归
- excel怎么固定第一行
- 外部中断(红外通信)
- org.hibernate.transaction.JDBCTransaction cannot be cast to javax.transaction.Transaction
- rhel 6.5 安装yum源
- 地表最强! Unity 5.x 插件合集专用贴 - 更新日期 2015.12.06
- Picasso图片下载缓存库的使用心得
- TF10187:Could not open document XXX.dbmdl
- VisualSVN Server添加svn项目
- IOS应用安全(五):高级Runtime分析和操作