Member-only story

Linux — How to Find All Files Containing Specific Text

Tony
6 min readOct 10, 2023

In the fast-paced world of DevOps, efficiently navigating and managing system configurations, code, logs, and more is crucial. One essential skill for every DevOps engineer working with Linux-based systems is the ability to rapidly locate files containing specific text or configuration settings.

In this article, we'll walk you through the use of different commands to streamline your DevOps workflow.

grep command

grep is a pattern searcher for text. It searches through files (or input) and prints lines that match a given pattern. This tool becomes indispensable when dealing with vast codebases, logs, or system configurations.

grep command one

$ grep -rnw '/path/to/folder/' -e 'pattern'
  • -r or --recursive: This option tells grep to search recursively. It will search through the specified directory and its sub-directories for the pattern.
  • -n or --line-number: With this option, grep will not only display the lines containing the pattern but will also prepend those lines with the line number within the file where the pattern was found.
  • -w or --word-regexp: This is a particularly useful option when you want to match whole words. By adding this option, grep will…

--

--

Tony
Tony

No responses yet