try typing the following:
grep --help
also try:
man grep
Note that both say that -P enables perl regular expressions. Here's a simple grep to print out all the UUIDS assigned in my fstab:
grep -o 'UUID=[-A-Za-z0-9]* ' /etc/fstab
It prints out this list:
UUID=ffdd991f-2fb5-4f7c-b45b-3d1923044e88
UUID=41fbf61a-6c4c-4a23-8864-d7a59d111a4e
etc
That's great. Now, I don't want to match the UUID= , as I'm using this in a script. So, I go ahead and enable perl regular expressions, and use lookbehind:
grep -oP '(?<=UUID=)[-A-Za-z0-9]* ' /etc/fstab
And, guess what? I get this:
grep: The -P option is not supported
That's a bit of a contrived example, but I found this bug for a very similar reason to the one I just described. Perl regular expressions aren't compiled in, even though both the man and --help say it is. That's a bug. Missing Perl Regex support is inconsistent with upstream's --help and man page at best, and breaks scripts (and admins) at worst. Sure, there are workarounds, but nothing quite matches the convenience of grep.
I'm glad that the Technical Board approved the change in regards to policy. That said, I respectfully disagree with this bug being demoted to wishlist. Hopefully I'll remember to ask around for a core dev to make this change when the Hardy+1 repos open.
Mr. Zimmerman,
try typing the following:
grep --help
also try:
man grep
Note that both say that -P enables perl regular expressions. Here's a simple grep to print out all the UUIDS assigned in my fstab:
grep -o 'UUID=[-A-Za-z0-9]* ' /etc/fstab
It prints out this list: 2fb5-4f7c- b45b-3d1923044e 88 6c4c-4a23- 8864-d7a59d111a 4e
UUID=ffdd991f-
UUID=41fbf61a-
etc
That's great. Now, I don't want to match the UUID= , as I'm using this in a script. So, I go ahead and enable perl regular expressions, and use lookbehind: )[-A-Za- z0-9]* ' /etc/fstab
grep -oP '(?<=UUID=
And, guess what? I get this:
grep: The -P option is not supported
That's a bit of a contrived example, but I found this bug for a very similar reason to the one I just described. Perl regular expressions aren't compiled in, even though both the man and --help say it is. That's a bug. Missing Perl Regex support is inconsistent with upstream's --help and man page at best, and breaks scripts (and admins) at worst. Sure, there are workarounds, but nothing quite matches the convenience of grep.
I'm glad that the Technical Board approved the change in regards to policy. That said, I respectfully disagree with this bug being demoted to wishlist. Hopefully I'll remember to ask around for a core dev to make this change when the Hardy+1 repos open.