1 |
On 11/22/2011 10:40 AM, Joerg Schilling wrote: |
2 |
>> Here's an alternative: |
3 |
>> |
4 |
>> sed -r -e 's/-[0-9].*//' |
5 |
> |
6 |
> Nust a note: sed has no option -r and 's/(.*)-[0-9].*/\1/' is a "garbled" |
7 |
> command. A corrected version would be 's/\(.*\)-[0-9].*/\1/' |
8 |
> |
9 |
> So the main question is: why do you use a non-existing option? |
10 |
> |
11 |
|
12 |
It does (at least, sys-apps/sed-4.2.1-r1 does): |
13 |
|
14 |
-r, --regexp-extended |
15 |
|
16 |
use extended regular expressions in the script. |
17 |
|
18 |
Appendix A Extended regular expressions |
19 |
*************************************** |
20 |
|
21 |
The only difference between basic and extended regular expressions is in |
22 |
the behavior of a few characters: `?', `+', parentheses, and braces |
23 |
(`{}'). While basic regular expressions require these to be escaped if |
24 |
you want them to behave as special characters, when using extended |
25 |
regular expressions you must escape them if you want them _to match a |
26 |
literal character_. |
27 |
|
28 |
------------------------- |
29 |
I just learned something new.... |
30 |
|
31 |
raf |