You are not logged in.

#1 2011-06-20 09:11:06

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,488
Website

[solved] Regex help...

I have a file with a bunch of functions like:

foo_dfljksdfk() {

}

foo_sdljkasd() {

}

foo_ladlafsd() {

}

So all functions start with "foo_" and have some sort of name afterwards.

I want to be able to extract a given function.  I thought something like

awk '/foo_name()/,/foo_....()/'

would be the way to go, but I do not know how to do the second regex.   I.e. name any foo_***() but not foo_name().

Any suggestions?

Offline

#2 2011-06-20 09:25:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Regex help...

Try

'!/foo_ladlafsd()/ && /foo_....()/'

Offline

#3 2011-06-20 09:42:04

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,488
Website

Re: [solved] Regex help...

Hmm...  that works...   Thanks!

But I found an even simpler way.  "type foo_sdfsasfd" in bash will echo the function.   And given the file is already sourced, that will make like easy!

Offline

Board footer

Powered by FluxBB