Mailinglist Archive: opensuse (3349 mails)

< Previous Next >
Re: [SLE] Need help with a sed script
  • From: Anders Johansson <andjoh@xxxxxxxxxx>
  • Date: Fri, 13 May 2005 00:20:30 +0200
  • Message-id: <200505130020.31326.andjoh@xxxxxxxxxx>
On Friday 13 May 2005 00:09, Greg Freemyer wrote:
> Anders,
>
> I see your online, maybe you can answer this fairly quickly for me.
>
> I don't use sed very often, how do I shift the first 2 chars of every
> line to chars 5 & 6.
>
> In otherwords if I have lines like:
>
> 123456rest of line.
>
> I need it to be:
>
> 345612rest of line.
>
> Reading a tutorial, I think it is something like:
> sed -e 's@^\(?\)\(?\)\(?\)\(?\)\(?\)\(?\)@\3\4\5\6\1\2@' file

Well, that looks like it might be made to work. This

sed -e 's/\(..\)\(....\)/\2\1/' file

seems to work when I just tried it.


< Previous Next >
Follow Ups
References