grep -inr command

The grep -inr command is a combination of several grep options used to search for a string in files and directories recursively. Here's a breakdown:

Syntax

grep -inr "pattern" /path/to/search

Options explained:

  • -iIgnore case (case-insensitive search)

  • -nShow line numbers in the output

  • -rRecursive search through directories

Example:

 
grep -inr "error" /var/log

This will search for the word "error" (case-insensitively) in all files under /var/log, displaying line numbers and filenames.

Sample output:

/var/log/syslog:103:error reading file /var/log/syslog:205:Error occurred while starting service

Let me know if you want to add more filters, like file extensions (--include="*.log") or excluding certain directories (--exclude-dir="tmp").

posted @ 2025-06-06 04:32  功夫 熊猫  阅读(34)  评论(0)    收藏  举报