awk regex /f[eo]{2}t/ does not work as advertised
Please refer to this article.
Quote:
Code:
$ awk '/f[eo]{2}t/' What am I to make of this? |
if you use gawk, use the --re-interval or --posix option to enable interval expressions. (ie {}).
|
Quote:
Code:
$ whereis gawk Should I just assume that the Awk language is broken on Ubuntu? |
There are at least two things wrong with that article.
First, it does not recognize that there are several varieties of awk out there. You"re running Kubuntu, right? My wife runs Xubunu, and her awk is mawk, just like yours, and it behaves just like yours. There seems to be no provision therein for interval expressions, and the [KX]ubuntu man page reflects this. On Slackware, when I ask for awk, I get GNU awk. Run in the normal manner, it doesn't have interval expressions either. But if you run it with the --posix option or the --re-interval option, interval expressions are allowed. Here's my experience with GNU awk: Code:
evans:~$ awk '/f[eo]{2}t/' Code:
/f[eo]{2}t/ Code:
feot |
getting gawk
You can install gawk on your Kubuntu system. Get the package from http://packages.debian.org/stable/gawk
|
Thank you for explaining it so well, wje_lq. That leads me to a conclusion and another question or two.
Quote:
What should I do when writing my own scripts to share? Quote:
It seems I won't be able to proceed with the tutorial any further unless I install gawk. Maybe I can figure out how to make it work with the alternatives system so that it doesn't break anything which may depend upon idiosyncrasies of mawk. :( |
i am really sceptical about gawk not being present. Why don't you try a find on your system to see if its really installed. the which command is not really foolproof in that it searches for $PATH only.
|
I was just using Kubuntu, and I know that when I ran "update-alternatives --all" awk was gawk by default. But anyways, all you have to do is install it if you don't have it. It has a higher priority and update-alternatives will set it as the default alternative automatically. If you ever have to change the alternatives, all you have to do is use "update-alternatives".
|
Quote:
Code:
$ aptitude search gawk Quote:
Code:
$ cd / |
Quote:
|
Quote:
As to whether I am satisfied, I have mixed feelings about this. I don't understand why my Kubuntu system shipped with a crippled Awk interpreter whereas other people's Kubuntu systems apparently did not. Maybe I should just chalk it up to Ubuntu's fickleness and add it to my list of reasons to move to Slackware. On the other hand I can't claim that my original post has not been satisfied, so I'll probably mark this one solved for now. |
Code:
$ gawk --posix '/f[eo]{2}t/' |
Quote:
EDIT: gawk might have been installed as a dependency when I was installing something else. I installed vim, build-essential, firefox, etc. Since it had a higher priority for update-alternatives, it could've just been made the default after it was installed as a dependency. |
I am running Ubuntu 10.04 and confirm that by default gawk is not available and mawk was the only option.
Upon getting more involved with [g]awk scripting I have since removed mawk as it had other limitations too, such as no gensub. |
I know that when I was going through the LFS book, it said to make sure that gawk was used, because mawk could not do the things that had to be done. I was using Debian, and it was using mawk by default.
|
All times are GMT -5. The time now is 11:36 AM. |