grep -q用于if逻辑判断
2015-10-08 13:49
459 查看
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
相关文章推荐
- Linux socket 初步
- android wifi 无线调试
- linux lsof详解
- linux 文件权限
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程