 |
Linux Format forums Help, discussion, magazine feedback and more
|
| View previous topic :: View next topic |
| Author |
Message |
tedius

Joined: Fri Apr 08, 2005 4:20 pm Posts: 83 Location: Cambridge, England
|
Posted: Mon Feb 12, 2007 9:46 am Post subject: regular expressions |
|
|
I have a structure with a member secno and I want to find all the files where a secno comparison is made. So I though that a egrep would do the job nicely, and I came up with this.
egrep ".*secno == .*secno.*" *.cc
Now I had run this command multiple times, changing the comparison function each time, i.e. ==, >, <, <=, >= and !=
Does anyone know if there is way I could have done all this with one regular expression rather than the 6 that I came up with.
Thanks |
|
| Back to top |
|
 |
MartyBartfast LXF regular

Joined: Mon Aug 22, 2005 8:25 am Posts: 780 Location: Hants, UK
|
Posted: Mon Feb 12, 2007 11:20 am Post subject: RE: regular expressions |
|
|
I think this will do what you want:
egrep ".*secno [=<>\!]=? .*secno.*" *.cc |
|
| Back to top |
|
 |
tedius

Joined: Fri Apr 08, 2005 4:20 pm Posts: 83 Location: Cambridge, England
|
Posted: Mon Feb 12, 2007 11:28 am Post subject: RE: regular expressions |
|
|
That Marty,
No that was my first attempt too, but that will also give you assignment.
I've now found a way though
egrep "secno (==|(<|>|\!)=?) .*secno" *.cc |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|