有时可能需要用sed ,awk同时匹配多个单词,总结了前辈们的方法,在我的CentOS 5下测试通过:
同时匹配xmdtyz和itlife365:
sed -n '/xmdtyz/{/itlife365/p}'
awk '/xmdtyz/&&/itlife365/{ print $0 }'
grep -E '(xmdtyz.*itlife365|itlife365.*xmdtyz)'
grep "a"|grep "b"
匹配xmdtyz或itlife365:
sed -n '/\(xmdtyz\|itlife365\)/p'
awk '/xmdtyz/||/itlife365/{ print $0 }'
grep -E '(xmdtyz|itlife365)'
from http://bbs.chinaunix.net/thread-1199427-1-1.html
网络,有不妥之处,请指教
同时匹配xmdtyz和itlife365:
sed -n '/xmdtyz/{/itlife365/p}'
awk '/xmdtyz/&&/itlife365/{ print $0 }'
grep -E '(xmdtyz.*itlife365|itlife365.*xmdtyz)'
grep "a"|grep "b"
匹配xmdtyz或itlife365:
sed -n '/\(xmdtyz\|itlife365\)/p'
awk '/xmdtyz/||/itlife365/{ print $0 }'
grep -E '(xmdtyz|itlife365)'
from http://bbs.chinaunix.net/thread-1199427-1-1.html
网络,有不妥之处,请指教
how-to-matching-multiple-words-by-use-sed-awk-grep