Shell 從文字檔找出某字串 - Linux

Table of Contents


請教各位, 利用 shell 從檔案 file 將字串 "asdf" 所屬的那行輸出至 file2 的語法為

sed -n "/asdf/w file2" file

如果現在我要將字串 "asdf" 或 "ffff" 所屬的那行輸出至 file2 的語法應該如何修改

謝謝

--

All Comments

Gilbert avatarGilbert2010-08-27
用xargs 試試看
Ursula avatarUrsula2010-08-31
能用grep去做嗎?
Queena avatarQueena2010-09-05
sed -n "/["asdf""ffff"]/w file2" file ??
Rachel avatarRachel2010-09-07
謝謝各位, 我最後是用 grep 做
Hamiltion avatarHamiltion2010-09-09
sed -nre'/(asdf|ffff)/w file2' file