[請益] 關於用Shellscript處理連續檔案的問題

看板Programming作者 (明天會更好)時間14年前 (2011/09/12 06:56), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
在linux下用shellscript處理連續的檔案時 如果檔案共有10個檔名分別為 test_01.out test_02.out test_03.out test_04.out test_05.out test_06.out test_07.out test_08.out test_09.out test_10.out 然後我想用grep來抓出每個檔案都含有keyword的那一行 按檔名01到10的順序寫到result檔案中 但有10個檔案,我知道用10次 grep 'keyword' test_01.out >> result 可以完成 但想請教一下有沒有更快的辦法 感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 99.90.128.88

09/12 08:55, , 1F
grep 'keyword' *.out >> result
09/12 08:55, 1F

09/12 10:10, , 2F
seq -w 10|xargs -i grep 'key' test_{}.o
09/12 10:10, 2F

09/12 10:10, , 3F
ut >> result
09/12 10:10, 3F
文章代碼(AID): #1ERJoi-k (Programming)
文章代碼(AID): #1ERJoi-k (Programming)