On Mon, 2003-09-08 at 22:29, Adam Hewitt wrote:
> Hi All,
> 
> I have a file which has lines in it like the following:
> 
> username1,password1,7200,10800
> username2,password2,7200,10800
> username3,password3,10800,10800
> 
> etc...and I need to turn the file into this:
> 
> username1     Password = "password1"
>       Idle-Timeout = 7200,
>       Session-Timeout = 10800,
>       Failover = 1
> 
> Would one of you kind sed guru's please give me some advise on how I
> could go about accomplishing this feat? This file is *long* and I refuse
> to have to sit there for hours cutting and pasting because of my
> scripting ignorance...and this needs to be done ASAP :(
> 
> Maybe I should get my arse into gear and start learning to program...

offhand, using my familiar hammer...

load up vim, then enter as one command:
%s/\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\)/\1\tPassword =
"\2"\r\tIdle-Timeout = \3,\r\tSession-Timeout = \4,\tFailover = 1

Rob

-- 
GPG key available at: <http://members.aardvark.net.au/lifeless/keys.txt>.

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to