Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 1st, 2012, 03:26 PM
sethwb sethwb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 70 sethwb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 27 m 54 sec
Reputation Power: 5
Regular expressions not working for grep??

Hello guys,

I'm trying to locate any template files in our file hierarchy that contain specific patterns... I'm familiar with regex... have been using it for a few years now with the assistance of regexr...

Now when I try using the syntax found on the man pages and many other how-to sites I never get any results, yet I know there are files with these patterns in them...

What the deal, yo?

Examples of patterns I'm using that simply do not return any results:

grep -r "radius\(" *
grep -r "maximum\-scale\=1" *
grep -r "\d+em\;" *


Any help provided on this matter is greatly appreciated.

Cheers,
S

Reply With Quote
  #2  
Old October 2nd, 2012, 09:50 AM
sethwb sethwb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2008
Posts: 70 sethwb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 27 m 54 sec
Reputation Power: 5
So... the man page says to use backslashes to escape these characters... yet people are telling me that is the opposite of what I should be doing...

HOWEVER, this is the story since those updates:

Hmmm isn't this example:

Quote:
grep -r 'radius(' *



the exact opposite of what the man page says below?
Quote:
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the backslashed versions \?, \+, \{, \|, \(, and \).



I did read the man page before posting here btw... it doesn't seem to make any sense.

When I try with the backslash in front of the parenthesis this is the return:

Quote:
$ grep -r 'radius\(' *
grep: Unmatched ( or \(


I am at the root where many files have multiple lines of CSS3 border-radius styles containing the exact spelling and capitalization as: "-radius(" -In fact I can look them up and open them in the folder tree using vi or nano... however this returns 0 results:

Quote:
$ grep -r 'radius(' *

Reply With Quote
  #3  
Old October 2nd, 2012, 10:33 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 37 m 21 sec
Reputation Power: 3885
You're misreading the man-page, though it might be clearer with an example.

In basic regexps (i.e. if you don't use the -e flag), they lose the special meanings that they normally have when used in regular expressions (i.e. they match the literal characters). Putting a backslash before a '(' character in basic mode turns it into a regular expression meta-character so the regexp engine expects that group to be closed with a corresponding '\)'. The is the opposite behaviour that you'd expect if you're used to PCREs.
Comments on this post
codergeek42 agrees!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Regular expressions not working for grep??

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap