Linux 搜尋檔案中的字串(grep)

搜尋某個目錄下的所有檔案內容是否包含某個字串,可以使用grep來達到
grep -rnw '目錄' -e '要搜尋的字串'

  • -r or -R is recursive (遞迴,包含搜尋子目錄)
  • -n is line number (顯示行號)
  • -w stands for match the whole word (符合配對的字串)

Reference: How do I find all files containing specific text on Linux?

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *