Search all files containing a specific string

How to search all files containing a specific string on Linux and Windows?

  • On Linux


    grep -rnw 'directory' -e "pattern"
    grep --include=\*.{txt,log} -rnw 'directory' -e "pattern"
    This will only search for files with .txt or .log extension.
    grep --exclude=*.txt -rnw 'directory' -e "pattern"
    This will exclude files with .txt extensions.
  • On Windows


    CD Location FINDSTR /L /S /I /N /C:"pattern" *.log

Filed under

Related articles

Level up your Tech Career with DjamgaTech PRO

Download the DjamgaTech PRO App on the Apple App Store to access hundreds of interactive prep questions, flashcards, and quizzes cleanly without ads.

Advertisement
Djamgatech PRO App
Download DjamgaTech PRO on the App Store 🚀

← All articles