[linux]GREP查詢特定檔案內含特定內容

linux指令, 架設等
回覆文章
頭像
tim
文章: 1379
註冊時間: 2008年 11月 26日, 00:49

[linux]GREP查詢特定檔案內含特定內容

文章 tim »

使用指令: grep

grep -ri --include="*.php" "select data from table" /var/www/site1

上述指令為 -r 包含子目錄, -i 為不區分大小寫, --include="*.php" 為指定 php 檔案, "select data from table" 為特定內容, 最後 /var/www/site1 為指定查找的起始目錄.

grep -ir --include="file_pattern" "text_pattern" directory

這樣的方式即可順利找出對應檔案的內容囉.
多多留言, 整理文章, 把經驗累積下來.....
回覆文章