If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to use pattern match with grep

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-27-06, 00:48
rei rei is offline
Registered User
 
Join Date: Jul 2004
Posts: 30
how to use pattern match with grep

hi,

i'm having problem like this.
i wish to grep some keyword from certain files in one directory.

let's say i have a lot of files in my directory with the name of file.1 file.2 file.3 ...... file.500
i only wish to grep the keyword from file.20, file.21, file.23 .... file.50

i tried the following command:
----------------------------
grep 'keyword' file.[20-50]
----------------------------

i used the command above and it returns no value.
i found that [20-50] is not the appropriate way to specify file.
anyone can guide me to this problem?
Reply With Quote
  #2 (permalink)  
Old 12-27-06, 05:00
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi,

The range specifier [min-max] applies to one character only. So [20-50] is not valid because there's no single character that represents '20' or '50'. [2-5] would be valid for the range file.2, file.3, file.4, file.5 but that's only part of the extension looked for. Thus the specifier '[2-5][0-9]' comes close but also returns the file.51, ...file.59 range so I would define the wanted range like this:
Code:
grep 'keyword' file.[2-4][0-9] file.50
Regards
Reply With Quote
  #3 (permalink)  
Old 01-05-07, 03:36
rei rei is offline
Registered User
 
Join Date: Jul 2004
Posts: 30
Quote:
Originally Posted by Tyveleyn
Hi,

The range specifier [min-max] applies to one character only. So [20-50] is not valid because there's no single character that represents '20' or '50'. [2-5] would be valid for the range file.2, file.3, file.4, file.5 but that's only part of the extension looked for. Thus the specifier '[2-5][0-9]' comes close but also returns the file.51, ...file.59 range so I would define the wanted range like this:
Code:
grep 'keyword' file.[2-4][0-9] file.50
Regards
i see !!!!
thanks for the help! have been figuring out for a long time!

i got another answer too
--------------------------------------
grep 'pattern' file.@([234][0-9]|50)
--------------------------------------
well, it's doing the same thing anyway

thanks !
Reply With Quote
  #4 (permalink)  
Old 01-17-07, 10:13
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Code:
file.{[2-4][0-9],50}
works as well.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 04-27-07, 11:55
falodun falodun is offline
Registered User
 
Join Date: Apr 2007
Posts: 1
pls i do i get simple shell script on how to monitor last transaction on the unix platform using seibel and genesy application and oracle db as the backend
Reply With Quote
  #6 (permalink)  
Old 04-28-07, 14:00
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You may want to ask your question in the Oracle forum if you want to monitor Oracle transactions, or find a suitable forum for Siebel/Genesy (whatever the latter is).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On