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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do i pattern match a field with awk? someone123 Shell Programming and Scripting 4 06-03-2008 09:08 AM
To identify filename in which having match PATTERN cedrichiu Shell Programming and Scripting 14 03-23-2008 08:05 PM
pattern match and substitution, can you help? frustrated1 Shell Programming and Scripting 4 02-20-2006 08:48 AM
How to pattern match on digits and then increment? sdutto01 Shell Programming and Scripting 2 08-11-2005 03:46 PM
match a pattern, print it and the next line nymus7 Shell Programming and Scripting 4 07-29-2005 01:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-27-2006
rei rei is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 3
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?
  #2 (permalink)  
Old 12-27-2006
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
how about
Code:
grep keyword file.??
  #3 (permalink)  
Old 12-27-2006
rei rei is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 3
Quote:
Originally Posted by andryk
how about
Code:
grep keyword file.??
thanks
that works but i want only file 20-50
?? will include 51-99, 10-19
  #4 (permalink)  
Old 12-27-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,538
try
Code:
grep "pattern" file.[2-5][0-9]
  #5 (permalink)  
Old 12-27-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Quote:
Originally Posted by ghostdog74
try
Code:
grep "pattern" file.[2-5][0-9]
The problem with that is that it would pick up everything from 20 to 59. For 20 to 50, try something like:
Code:
grep 'pattern' file.@([234][0-9]|50)
  #6 (permalink)  
Old 01-05-2007
rei rei is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 3
Quote:
Originally Posted by Glenn Arndt
The problem with that is that it would pick up everything from 20 to 59. For 20 to 50, try something like:
Code:
grep 'pattern' file.@([234][0-9]|50)
i see !!!!
thanks for the help! have been figuring out for a long time!
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 04:29 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