Searching for Text While Ignoring Case

Problem

You need to search for a string (e.g., “error”) in a log file, and you want to do it caseinsensitively to catch all occurrences.

Solution

Use the -i option on grep to ignore case:

 $ grep -i error logfile.msgs

Discussion

A case-isensitive search finds messages written “ERROR”, “error”, “Error,” as well as ones like “ErrOR” and “eRrOr.” This option is particularly useful for finding words anywhere that you might have mixed-case text, including words that might be capitalized at the beginning of a sentence or email addresses.

See Also

  • man grep

  • man regex (Linux, Solaris, HP-UX) or man re_format (BSD, Mac) for the details of your regular expression library

  • Mastering Regular Expressions by Jeffrey E. F. Friedl (O’Reilly)

  • Chapter 9’s discussion of the find command and its -iname option

  • Expecting to Change Exported Variables

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.231