[英]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.