IPB

Welcome Guest ( Log In | Register )


 
Reply to this topicStart new topic
> cygwin
chook
post May 27 2009, 08:46 PM
Post #1


Oh baby bring me down
Group Icon

Group: Agents
Posts: 4,115
Joined: 23-February 06
From: Way out yonder
Member No.: 68



Damn my bash skills are rusty. I am trying to use the find command with regular expressions to collect a list of .cpp and .h files that reside in the child directories of my current directory. Its been bothering me at work that I cannot get both those file types with a single regular expression. Anyone an expert on this? I can do this and use a temp file before I merge and sort the lists, but I didn't want to use it. Anyone got any good advice on scripts?

The machine also has python on it, and I can't use perl on it. crying.gif

Thanks!


--------------------
Southern Rock, beer and bears!
Go to the top of the page
 
+Quote Post
impala454
post May 27 2009, 08:58 PM
Post #2





Group: Members
Posts: 10,620
Joined: 23-February 06
From: Houston, TX
Member No.: 48



CODE
find . -regex ".*\.cpp\|.*\.h"
Go to the top of the page
 
+Quote Post
chook
post May 28 2009, 10:56 AM
Post #3


Oh baby bring me down
Group Icon

Group: Agents
Posts: 4,115
Joined: 23-February 06
From: Way out yonder
Member No.: 68



QUOTE (impala454 @ May 27 2009, 09:58 PM) *
CODE
find . -regex ".*\.cpp\|.*\.h"

Thanks Chuck, I was trying to pass the or without the escape key. I guess does bash try to do its own interpertation of it instead of letting the find do it?

CODE
find . -regex ".*\.cpp|.*\.h"[/


--------------------
Southern Rock, beer and bears!
Go to the top of the page
 
+Quote Post
impala454
post May 28 2009, 12:27 PM
Post #4





Group: Members
Posts: 10,620
Joined: 23-February 06
From: Houston, TX
Member No.: 48



You have to escape the pipe to let it know it's part of the regex and not the string you're looking for. I know it's weird but yeah you can have a pipe in a filename.
Go to the top of the page
 
+Quote Post
chook
post May 28 2009, 12:55 PM
Post #5


Oh baby bring me down
Group Icon

Group: Agents
Posts: 4,115
Joined: 23-February 06
From: Way out yonder
Member No.: 68



QUOTE (impala454 @ May 28 2009, 01:27 PM) *
You have to escape the pipe to let it know it's part of the regex and not the string you're looking for. I know it's weird but yeah you can have a pipe in a filename.

My understanding of what an excape is was wrong. I thought of it as an excape from bash interpeting it as a pipe to a another function and not find's interperter. Makes sense.

What also frustrated me is that even though the man page said the egrep program said it followed POSIX specs, I had to use ASCII specs to parse it. Was frustrating because it worked sometimes and not other times. Thought it had something to do with unicode or my delimiters being screwed up.


--------------------
Southern Rock, beer and bears!
Go to the top of the page
 
+Quote Post
FORSAKENR320
post May 28 2009, 09:33 PM
Post #6


GORILLA FLUFFER
Group Icon

Group: Agents
Posts: 7,705
Joined: 23-February 06
From: lubbock
Member No.: 50



QUOTE (chook @ May 27 2009, 09:46 PM) *
I am trying to use the find command with regular expressions to collect a list of .cpp and .h files that reside in the child directories of my current directory.


this sounded like you were searching for CP (child pornography) to me. heh






--------------------
QUOTE (Jessica @ May 7 2007, 01:15 PM) *
but yeehaw dammit. YEEHAW
QUOTE (Dogmeat @ Jun 26 2008, 07:51 PM) *
ok once upon a time I jacked myself off retarded.


Licking anuses, one kindergarten class at a time!!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 19th October 2018 - 04:06 PM
Skin made by: skeedio.com