[nycbug-talk] Scripting Question
Scott Robbins
scottro at nyc.rr.com
Thu Mar 8 11:39:45 EST 2007
On Thu, Mar 08, 2007 at 11:13:33AM -0500, Kevin Reiter wrote:
> -----Original Message-----
> From: Ray Lai [mailto:ray at cyth.net]
> Sent: Thursday, March 08, 2007 11:07 AM
> To: Kevin Reiter
> Subject: Re: [nycbug-talk] Scripting Question
>
>
> On Thu, Mar 08, 2007 at 11:00:20AM -0500, Ray Lai wrote:
> > On Thu, Mar 08, 2007 at 10:44:19AM -0500, Kevin Reiter wrote:
> > > All,
> > >
> > > I know this doesn't pertain to *BSD specifically, but I know there are scripting gurus in here that may know how to do this.
> > >
> > > What I'm trying to do is take a file containing a list of numbers, in the form of:
> > >
> > > 1
> > > 2
> > > 3
> > > 4
> > > 5
> > >
> > > and convert it to a comma-delimited list on a single line (i.e. 1,2,3,4,5) and write that to an existing file on a specific line.
> >
> > $ jot -s, 5
Just for fun (and because I ~like~ jot)
Call the original file test
#!/bin/sh
Y="$(wc -l test)"
jot -s "$Y" < test
worked perfectly.
Kevin's solution is more elegant (and more robust I think).
It proves the adage that in Unix (and of course, Unix-like systems)
there's always more than one way to do something. (The corollary is
that somone will think your way is stupid.) :)
--
Scott Robbins
GPG KeyID EB3467D6
( 1B848 077D 66F6 9DB0 FDC2 A409 FA54 D575 EB34 67D6)
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6
Angel: She murdered a man right in front of me, and I can't
even testify to that fact in a court of law.
Cordelia: Well, maybe in night court you could...
More information about the talk
mailing list