On Mon, 2003-09-08 at 22:29, Adam Hewitt wrote:
> 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 :(
I'd have thought awk would be better for this than sed. And awk is one
of those things that only looks hard until you've tried it. :-)
Actually, like most things, the hardest part seems to be figuring out
how to escape stuff from the shell properly.
Also like sed, it has a very thorough man page, with lots of
easy-to-follow examples.
Something like:
$ cat original-file | awk -F, '{ print $1"\tPassword = \""$2"\""
print "\tIdle-Timeout = "$3","
print "\tSession-Timeout = "$4","
print "\tFailover = 1" }' > new-file
should do the trick, but I haven't really tested it. Hopefully it's
clear enough to understand and make work properly. :-)
--
Pete
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug