[英]How can I use grep to retrieve two patterns within the same fixed-length sections of text?
[英]How to use grep with two patterns?
我關注了許多鏈接和參考文檔,但仍然遇到錯誤。 我想列出所有以“ sx”開頭或結尾的單詞。 我已經找到了可以正常工作的解決方案:
awk '/^sx|sx$/' usr/dict/words
但是我嘗試使用grep或egrep,但都沒有用。 然后我簡化了。 包含“ ax”或“ sx”的任何單詞,再次都無效!
grep 'ax|sx' words
grep -E '^ax\|sx$' words
egrep '^ax\|sx$' words
錯誤:
grep: illegal option -- E
Usage: grep -hblcnsviw pattern file . . .
任何建議表示贊賞。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.