大量搜尋文字檔內的資料 - Linux

Table of Contents

我在某個資料夾底下有相當多的資料夾
每個資料夾裡面又有許多不同的檔案

./xxx/aaa/
123.txt
456.txt
./xxx/bbb
123.txt
456.txt
./xxx/ccc
12.txt
34.txt
....


想請問的是
我想要去找這些檔案裡面,包含某個特定關鍵字的文件

如果檔案全部在同一個資料夾
我只要簡單的下
grep "keyword" *.txt 即可

但現在分散在這麼多資料夾
有什麼比較好得方法呢?

--

All Comments

Ursula avatarUrsula2009-11-19
grep -r keyword ./
Zenobia avatarZenobia2009-11-20
find ./ -iname "*.txt" | grep keyword
Gilbert avatarGilbert2009-11-20
樓上推錯補推 find ./ -iname "*.txt" -print0 | xargs -0 \
grep keyword
Lauren avatarLauren2009-11-22
成功了~:D 感謝
Heather avatarHeather2009-11-25
find ..... -exec grep keyword {} +
George avatarGeorge2009-11-26
grep keyword `find . -iname "*.txt"`