Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings.

To accomplish this, I've been running the following from the command line:

find . -name "*" | xargs grep "[tT] [hH] [iI] [sS]" | grep "[tT] [hH] [aA] [tT]" > output.txt

Two grep statements are needed in case I'm looking for a name that needs both first and last name.

I'd like to have a shell script that could do this, where I run the script from the command line and enter the strings as arguments at run time. My biggest question is how do I ensure in the variable that both lowercase and uppercase letters are searched for each letter.

I haven't written a shell script in a long time so I'm very rusty. :slight_smile:

Thanks for any help.

I would guess you want something like this:

find . -name '*' -exec grep -i -e 'this' -e 'that' {} \; > output.txt

This finds the two words: 'this' or 'that', regardless of capitalization.

Ah, so a grep -i would ignore case? Cool, what would the -e do? Stupid question I know....

dkozel$ man grep | grep -e '-e' -A2
       grep [options] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION
--
       -E, --extended-regexp
              Interpret  PATTERN  as  an  extended  regular  expression  (see
              below).
--
       -e PATTERN, --regexp=PATTERN
              Use  PATTERN  as the pattern; useful to protect patterns begin-
              ning with -.
--
         --exclude=PATTERN
              Recurse in directories skip file matching PATTERN.

multiple -e's can be used to specify several search terms

dkozel$ grep "term one\|term two\|term three" filename.txt

ps: -A# shows # lines after search result