Date: Wed, 09 Nov 2011 11:27:34 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Vincent Hoffman <vince@unsane.co.uk> Cc: "FreeBSD-Questions@freebsd.org" <FreeBSD-Questions@freebsd.org> Subject: Re: sed vs gnu sed Message-ID: <4EBA63A6.7070006@infracaninophile.co.uk> In-Reply-To: <4EBA5646.5030102@unsane.co.uk> References: <4EBA5646.5030102@unsane.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 09/11/2011 10:30, Vincent Hoffman wrote:
> is there any easy way to make our sed do the same as gnu sed here?
> for now I have encapsulated the whole thing in a subshell
> [backup@banshee ~]$ echo -n $(echo -n "/boot:7:1:5; /:7:1:5;
> /var:7:1:5" | sed -n 's/[[:space:]]*;[[:space:]]*/;/gp')
> /boot:7:1:5;/:7:1:5;/var:7:1:5[backup@banshee ~]$
>
> Which works but seems a little hackish.
You can do it with awk(1):
# echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | \
awk ' { gsub("[[:space:]]*;[[:space:]]*", ";", $0) ; printf "%s", $0 }'
Not sure if that's any better than your solution using echo though.
Also trivial in perl(1) or python(1) or whatever, but it seems a waste
to fire up a whole perl interpreter just to do that.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matthew@infracaninophile.co.uk Kent, CT11 9PW
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EBA63A6.7070006>
