ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I didn't really take a good look at it, but it sounds like a replacement for something like test $( echo string | egrep -c '^regex$' ) -eq 1? Certainly more graceful.
ta0kira
no, I don't think so. I'll illustrate its usage with an example:
say I want to find all instances in the linux kernel
of :
Code:
x = kmalloc(sizeof(y), GFP_KERNEL)
And I came up with this, which I fed this to my (bash) term:
Code:
al_="[A-Za-z_]";
an_="[A-Za-z0-9_]";
int="[0-9]"
hex="[a-f0-9]"
#whitespace
s="[[:space:]]*";
S="[[:space:]]+";
# to match something like 1ul, floats or hexes as well:
D="$int*\.?$int+x?$hex*[uUlL]{0,3}[fF]?"
# can be used for a variable/function name
V="$al_+$an_*";
# same, but also catches variables that are members or arrays
w="($V|${V}\[$s$an_*$s\]|$V\.|$V->)+"
# match the end of the line, including comments
cendl="$s(\/[*\/].*)?$"
git grep -E "$s$w$s=${s}kmalloc$s\(${s}sizeof$s\($s$w$s\)$s,GFP_KERNEL$s\)$s;$cendl"
But it only finds one match, there's obviously something wrong with my match. I look and find in drivers/atm/nicstar.c, line 920:
Oh, I see now. It took me a while to get it. So you feed the script an expression and a string, knowing it isn't a match, then your script tells you where exactly the discrepancy is since you only have match/no-match otherwise? That sounds very useful.
ta0kira
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.