Junior — Middle
How can you search for a specific string within a file in the Linux operating system?
sobes.tech AI
Answer from AI
To search for a specific string within a file in Linux, the grep command is usually used.
Example:
grep "search_string" filename
This will output all lines from the file that contain "search_string".
To search recursively in all files within a directory:
grep -r "search_string" /path/to/directory
Useful options include:
-i— ignore case-n— show line number-v— show lines that do not contain the search string
Thus, grep is a simple yet powerful tool for searching text within files.