On Tue, Jun 28, 2011 at 4:50 PM, Kent Fredric <[email protected]> wrote:
> On 28 June 2011 16:26, Jim Cheetham <[email protected]> wrote:
>> sed and awk can do pretty much anything. The syntax is ugly as hell,
>> and not readable for updates later, and that's why we have better
>> languages now.
>
> I should also point out on some Unixen, 'sed -r' may not exist or may
> not work the way you expect it to.
Agreed. It's on solaris, but I don't think it's on *bsd.
In any case, all the -r is doing as far as I can be bothered telling,
is allowing me to use {count} and () without resorting to quoted
brackets and explicit counts.
This one works without the extended regexp ...
echo abcdefghijklmnopqrstuvwxyz | sed -e '
s/^\(.....\)\(.*\)$/\1Z\2/
:groupsoffour
s/^\(.*Z\)\([^Z][^Z][^Z][^Z]\)\([^Z]*\)$/\1\2Z\3/
t groupsoffour
s/^\(.....\)Z\(.*\)$/\1\2/
> However, that perl syntax /should/ work on everything, including
http://bellard.org/jslinux/ is a busybox machine, for example ... that
doesn't have perl, but it does have a decent sed :-)
I'm not sure if it works, because it is taking *ages* to execute ...
and I don't think I can wait that long!
Just noting that not all Unix boxes are big enough to run
(perl|ruby|whatever) ... however in practice, if your box isn't big
enough to run perl, perhaps you shouldn't run large regexps and do odd
text processing anyway!
-jim
_______________________________________________
Linux-users mailing list
[email protected]
http://lists.canterbury.ac.nz/mailman/listinfo/linux-users