Forum unknown
· Programming
#ARP again!
13 messages in this thread
Yes, using 'regular expressions' (for those who don't know, grep
stands for General Regular Expression Parser) there are several options:
? = zero or one occurance
+ = one or more occurances
. = any one character
* = 0 or more occurances of the preceding character
eg: /a?x/ matches 'x' and 'ax'
/a+x/ matches 'ax', 'aax', 'aaaax' and so on
/a.x/ matches 'aax', 'abx', 'acx' and so on
/a*x/ matches 'x', 'ax', 'aax', 'aaax' and so on
Don
GREP actually stands for "Global Regular Expression Print", because that's
what you type in the UNIX editor (ed) to do what grep does:
g/re/p
where re is the regular expression.
There used to also be a "gres", "Global Regular Expression Substitute", once
again based on the UNIX ed command:
g/re/s
which you follow by the substitute pattern, like so:
g/re/s//replacement/
but it got left out of Version 7 and subsequent versions because it was
replaced by the Stream Editor, "sed", which gave you the ability to perform
all the editor commands in a stream fashion:
sed '/re/s//replacement/'.
Perhaps someone who has more free time than I could take the PD grep source
and put in a substitute option.
There is also a PD version of the unix ED editor available, in 'C'. I keep it
around. If it hasn't been uploaded yet I might be persuaded to arc my copy
up.
Well…I'll defer to you, but that's not the way I heard it. I'll
have to take a look in my AT&T manuals when I get to work tommorow. But,
yes,
:g/string/s//replacement/
works fine with ed or vi, etc. I use it all the time.
They stripped a lot of neat stuff out of the manuals over the years,
especially etymological notes like that.
Since you prompted my curiosity, I checked my UNIX manuals (both
the 'store bought AT&T' manuals and the looseleaf manuals that came with
our 3B2-600's)…you're right, it is Global Regular Expression Printer.
It's still in the manuals…but in an obscure spot.
Since you prompted my curiosity, I checked my UNIX manuals (both
the 'store bought AT&T' manuals and the looseleaf manuals that came with
our 3B2-600's)…you're right, it is Global Regular Expression Printer.
It's still in the manuals…but in an obscure spot.
They stripped a lot of neat stuff out of the manuals over the years,
especially etymological notes like that.
Well…I'll defer to you, but that's not the way I heard it. I'll
have to take a look in my AT&T manuals when I get to work tommorow. But,
yes,
:g/string/s//replacement/
works fine with ed or vi, etc. I use it all the time.
GREP actually stands for "Global Regular Expression Print", because that's
what you type in the UNIX editor (ed) to do what grep does:
g/re/p
where re is the regular expression.
There used to also be a "gres", "Global Regular Expression Substitute", once
again based on the UNIX ed command:
g/re/s
which you follow by the substitute pattern, like so:
g/re/s//replacement/
but it got left out of Version 7 and subsequent versions because it was
replaced by the Stream Editor, "sed", which gave you the ability to perform
all the editor commands in a stream fashion:
sed '/re/s//replacement/'.
Perhaps someone who has more free time than I could take the PD grep source
and put in a substitute option.
There is also a PD version of the unix ED editor available, in 'C'. I keep it
around. If it hasn't been uploaded yet I might be persuaded to arc my copy
up.
Well, you were close… grep comes from Global/Regular Expression/Print,
which is from some editor or another, and seen there in the form:
g/<regular experssion>/p
Well, you were close… grep comes from Global/Regular Expression/Print,
which is from some editor or another, and seen there in the form:
g/<regular experssion>/p
Thanks Don, I was sure that you can create just about any pattern and
sepecify both limited and unlimited options. 73, bill
Thanks Don, I was sure that you can create just about any pattern and
sepecify both limited and unlimited options. 73, bill