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
Problem with GREP. syndex Shell Programming and Scripting 2 07-11-2007 01:44 PM
Grep Problem avadhani UNIX for Dummies Questions & Answers 8 06-23-2005 02:58 PM
grep problem asal_email2 UNIX for Dummies Questions & Answers 4 06-22-2005 08:49 PM
Grep Problem lesstjm Shell Programming and Scripting 2 10-27-2004 10:13 AM
Grep problem odogbolu98 Shell Programming and Scripting 3 02-18-2003 03:53 PM

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 11-05-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
grep problem

just a file with thousands of filenames and I wanna get all files with the same extension, like .Z

for example....
users/123/a.Z
users/424234/fafa.Z
users/424234/asda.log
daa/dsss/222/efesa-01002-01:00-A.Z

how to solve this issue?

when you make..

grep .Z file >newfile
grep ".Z" file >newfile
grep '.Z' file >newfile

..it finds only all files with a 'Z' in its filename.

also grep -x (exact) isn't the correct solution, because 0 files.

thx for any advice....
  #2 (permalink)  
Old 11-05-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
grep "\.Z$" file > newfile

This indicates to match .Z followed by the end of the line.

Cheers
ZB
  #3 (permalink)  
Old 11-05-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
thx, working perfect....

^ - beginning
\ - ending of the line ?

what about the $ ?
  #4 (permalink)  
Old 11-05-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
^ - beginning of line
$ - end of line
\. - backslash escaped "." - to stop it being interpreted as a metacharacter - i.e. a literal full-stop.

Cheers
ZB
  #5 (permalink)  
Old 11-05-2004
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
\ is to escape the dot (.). In regular expression, a dot matches any single character. Escaping it means to treat the metacharacter (i.e. the dot in this case) literally.

$ matches the end-of-line. So, if you don't want to match something like .Za .ZIP etc. don't forget to have the $ in.
  #6 (permalink)  
Old 11-08-2004
svennie svennie is offline
Registered User
  
 

Join Date: Sep 2004
Posts: 78
thx..
Sponsored Links
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 01:59 AM.


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