[英]How to grep just strings "ip" into a file?
我试图找到在某些文本中查找字符串的各种方法。 我想找到更多使用 grep 或 sed 的方法。 (请记住它区分大小写)
grep ip /usr/share/dict/words/ > /root/found
grep ^ip /usr/share/dict/words > /root/found
grep ^ip$ /usr/share/dict/words > /root/found
如果您更喜欢使用>
将输出附加到文件 /root/found 中,则必须使用>>
无论大小写,都可以使用 Grep:
grep -i "ip" /ust/share/dict/words >> /root/found
如果要搜索 /ust/share/dict/words 的子目录和当前目录中的所有文件
find /ust/share/dict/words -name "*" -exec grep "ip" '{}' \; -print >> /root/found
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.