Need to Write Shell Script based off of this shell command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to Write Shell Script based off of this shell command
# 1  
Old 06-10-2009
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. Smilie

Thanks for any help.
# 2  
Old 06-10-2009
I would guess you want something like this:
Code:
find . -name '*' -exec grep -i -e 'this' -e 'that' {} \; > output.txt

This finds the two words: 'this' or 'that', regardless of capitalization.
# 3  
Old 06-10-2009
Quote:
Originally Posted by jim mcnamara
I would guess you want something like this:
Code:
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....
# 4  
Old 06-10-2009
Code:
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

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

ps: -A# shows # lines after search result
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help me to write the shell script

Please help me to write the shell script AC|NAME|STATE|MAXVALUE|MINVALUE---------heading 111|UMA|ODISHA|123,00.00|54.00 111|UMA|ODISHA|124,00.00|25.00 111|UMA|ODISHA|114,00.00|58.00 111|UMA|ODISHA|104,00.00|00.00 111|UMA|ODISHA|194,00.00|19.00 111|UMA|ODISHA|184,00.00|64.00... (5 Replies)
Discussion started by: alokjyotibal
5 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

To write shell script based on 1 and 4th columns

Hi, I am trying to write shell script for below requirement File has below values @mqm soft nproc 75000 @mqm hard nproc 75000 @mqm soft nofiles 76492 @mqm hard nofiles 76492 @mqm soft locks 76492 @mqm hard ... (7 Replies)
Discussion started by: darling
7 Replies

5. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

6. Shell Programming and Scripting

how to write shell script

Hi , i need to write a script like this In 1.sh ./test.sh wait(5sec) send ctrl+C to server ./testxxxx.sh first i need invoke test.sh from 1.sh , after wating for some time i need to close the test.sh script & i need to start new script i tried to invoke script... (2 Replies)
Discussion started by: pvr_satya
2 Replies

7. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

8. Shell Programming and Scripting

write a shell script to execute a command

Hello all, I have just started doing shell scripting. I want to read a file which stores the status of my job I have submitted on a cluster. The file looks something like this : ========================FILE============================= crab: Checking the status of all jobs: please wait... (4 Replies)
Discussion started by: learn_linux
4 Replies

9. UNIX for Dummies Questions & Answers

how to write perl substitute command in shell scripts

How to write perl substitute command in shell script without invoking a perl script file seperately. for ex: shell script to relace IT with CSC in a file using perl substitute command. (3 Replies)
Discussion started by: param_it
3 Replies

10. Shell Programming and Scripting

please Write a shell script

Hi Team, I am unable to write script. please guide me. My rquirement is as given below one file will have three columns with n number of rows like hostname port sid -------- ---- --- sun056 1527 PSP1 sun111 1529 PRP1 sun107 1580 PRD1 the script should... (6 Replies)
Discussion started by: rvrao77
6 Replies
Login or Register to Ask a Question