[英]How to grep just strings "ip" into a file?
I am trying to find every way to find a string in some text.我试图找到在某些文本中查找字符串的各种方法。 I want to find more ways using grep or sed.我想找到更多使用 grep 或 sed 的方法。 (bear in mind It's case sensitive) (请记住它区分大小写)
grep ip /usr/share/dict/words/ > /root/found
grep ^ip /usr/share/dict/words > /root/found
grep ^ip$ /usr/share/dict/words > /root/found
If you prefer to append output into file /root/found instead using >
you have to use >>
如果您更喜欢使用>
将输出附加到文件 /root/found 中,则必须使用>>
Grep over irrespective of case:无论大小写,都可以使用 Grep:
grep -i "ip" /ust/share/dict/words >> /root/found
If you want to search all files in sub directories and current directories of /ust/share/dict/words如果要搜索 /ust/share/dict/words 的子目录和当前目录中的所有文件
find /ust/share/dict/words -name "*" -exec grep "ip" '{}' \; -print >> /root/found
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.