[問題] grep -R?

看板Linux作者 (並不代表爛)時間16年前 (2009/12/07 11:32), 編輯推噓4(409)
留言13則, 4人參與, 最新討論串1/1
[root@localhost boot]# ls config-2.6.29.4-167.fc11.i686.PAE lost+found config-2.6.30.9-99.fc11.i686.PAE System.map-2.6.29.4-167.fc11.i686.PAE efi System.map-2.6.30.9-99.fc11.i686.PAE grub vmlinuz-2.6.29.4-167.fc11.i686.PAE initrd-2.6.29.4-167.fc11.i686.PAE.img vmlinuz-2.6.30.9-99.fc11.i686.PAE initrd-2.6.30.9-99.fc11.i686.PAE.img [root@localhost boot]# grep -R 10 *.lst grep: *.lst: 沒有此一檔案或目錄 [root@localhost boot]# =====================在boot 目錄下以遞迴方式 用grep搜尋 "10"這個字串 說找不到 但 [root@localhost boot]# cd grub [root@localhost grub]# grep 10 *.lst timeout=10 [root@localhost grub]# 其實明顯的在grub目錄下 有內容為10的這個字串 這是bug嗎 還是我有哪裡用錯呢?? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.25.90

12/07 14:07, , 1F
感覺應該是-R只能接資料夾
12/07 14:07, 1F

12/07 14:07, , 2F
用看看find -name '*.lst' -exec grep 10 {} +
12/07 14:07, 2F

12/07 14:23, , 3F
grep -R -e '10' *.lst
12/07 14:23, 3F

12/07 14:25, , 4F
grep -R -e '10' */*.lst 這樣才對
12/07 14:25, 4F

12/07 15:04, , 5F
*/* 是指path的意思嗎 抱歉問題很笨XD
12/07 15:04, 5F

12/07 15:07, , 6F
不過我手邊的書就直接是這樣打耶 grep -R String *.*
12/07 15:07, 6F

12/07 16:43, , 7F
hmm 我打*/*是假裝知道grub.conf在第幾層了 還是失敗 XD
12/07 16:43, 7F

12/07 16:43, , 8F
*.lst
12/07 16:43, 8F

12/07 18:05, , 9F
regular expression *代表出現0次或無限多次的所有字元
12/07 18:05, 9F

12/07 18:06, , 10F
但比較奇怪是說 為什麼不打*就好
12/07 18:06, 10F

12/07 18:07, , 11F
還是這樣只代表搜尋兩層 不是所有層都可以搜尋到呢
12/07 18:07, 11F

12/08 18:49, , 12F
是因為先被bash 展開 *.lst
12/08 18:49, 12F

12/08 18:51, , 13F
find . -type f -name '*.lst' -exec grep 10 {} \;
12/08 18:51, 13F
文章代碼(AID): #1B77T2_8 (Linux)