The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To find multiple strings count in a file salaathi Linux 3 11-28-2007 06:31 AM
Search for strings & copy to new file amitrajvarma Shell Programming and Scripting 2 11-25-2007 11:51 PM
Problem to search multiple strings sudhish Shell Programming and Scripting 2 10-25-2007 02:00 PM
string search in folders with particular multiple file extension anikanch UNIX for Dummies Questions & Answers 2 10-28-2005 10:09 AM
searching for filenames with search strings in another file pathanjalireddy Shell Programming and Scripting 3 06-08-2005 05:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-18-2008
deepakpv deepakpv is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 11
How to search multiple strings in a file

Hi All,

I want to search all the ksh scripts that has following details.
1. Search for "exit 0"
2. Search for "sqlldr" or sqlplus"
3. In the above files i want to search for all the script that has no "case" in it.

Please advice.

Thanks,
Deep
  #2 (permalink)  
Old 09-19-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Try this:

Code:
grep -l 'exit 0' *.ksh | xargs grep -El 'sql(ldr|plus)' | while read file
do
    grep -q case $file || echo $file
done
Or this:

Code:
for f in *.ksh
do
    awk '/exit 0/ {e=1} /sql(ldr|plus)/ { s=1 } /case/ { c=1 } END { if (e && s && !c) { print FILENAME } }' $f
done
  #3 (permalink)  
Old 09-19-2008
deepakpv deepakpv is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 11
Thanks a lot Annihilannic.
I will test this.

Regards,
Deepak
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0