I want to know a single regular expression that can match these 2 words in a file "saxena" and "saksena" they have only the "ks" and "x" different in them i can use
but i thought as the "ena" part was also common there must be some other way to match them. also which is the best site to learn about regular expression?
Also how do we grep whitespace and strings which may be regular expressions in a file??
rich_m wrote:
I want to know a single regular expression that can match these 2 words in a file "saxena" and "saksena" they have only the "ks" and "x" different in them i can use
but i thought as the "ena" part was also common there must be some other way to match them. also which is the best site to learn about regular expression?
Also how do we grep whitespace and strings which may be regular expressions in a file??
p.p.s. our university unix (Sun) environment is a mess. software is severely outdated, doesn't agree with manpages.. webspace is run by incompetent morons..
Some more questions...
How do you delete lines containing whitespace from a file?
I tried using 'tr' in this way but only lines containing space get deleted (not the ones with tab spaces
also related to this i have another question
How do we count the lines having at least one space or tab?
the -v option again does not match TABS. Any idea why?
Remember that grep prints lines with a match; that is, any line that contains a match. If you only want lines that match in full, then you must use anchors to match the beginning and end of the line. Beginning is ^ (which only makes sense in the beginning, since we are matching line at a time) and end is $ (in the end, ofcourse).
What happens is probably that [:xdigit:] matches the same as [0-9a-f]{1,4}. Since you aren't matching anything after that, the upper bound 4 is meaningless (other than for capture purposes for things like sed), and since you have lower bound 1, and no meaningful upperbound, you could just as well just use [:xdigit:], so you get any lines with at least one 0-9 or a-f.
Why :xdigit: doesn't seem to match A-F as well, I don't know, unless ofcourse you are doing this on Solaris, where I've yet to understand the internal logic of :xdigit: as it seems to match numbers, or hexadecimal digits prefixed by 0x... or something like that... which makes little sense to me.
mystran wrote:
Why :xdigit: doesn't seem to match A-F as well, I don't know, unless ofcourse you are doing this on Solaris, where I've yet to understand the internal logic of :xdigit: as it seems to match numbers, or hexadecimal digits prefixed by 0x... or something like that... which makes little sense to me.
Does that make sense?
I was using CYGWIN.
and with the pattern you spoke of this is what I got
is broken / not enabled, and that it is greping for any line containing the letters x, d, i, g, or t? That would explain the results just nicely, although I have no idea how it could come about.
Every good solution is obvious once you've found it.