From: Andrew McDermott on
Kenny McCormack wrote:

> In article <MP6dneh2BdV5CdTRnZ2dnUVZ_sydnZ2d(a)giganews.com>,
> hehe2046 <user(a)compgroups.net/> wrote:
>>I would say: sed -i "s/.*/'&',/" input.txt
>>
>>
>
> Or, more sensibly:
>
> awk '{print "\047"$0"\047"}' ...

You missed the comma, by the way.
>
> Tip: Avoid cryptic, meaningless tools like "sed" (and friends).
>

How is 'print "\047"$0"\047" less cryptic than the above sed line?

Sorry, I don't want to start an awk V sed flame war, but let's face it, that
so-called tip IS flame-bait.

Andrew
From: Barry Margolin on
In article <i2cf5j$982$1(a)south.jnrs.ja.net>,
Andrew McDermott <a.p.mcdermott(a)NOSPAM-rl.ac.uk> wrote:

> Kenny McCormack wrote:
>
> > In article <MP6dneh2BdV5CdTRnZ2dnUVZ_sydnZ2d(a)giganews.com>,
> > hehe2046 <user(a)compgroups.net/> wrote:
> >>I would say: sed -i "s/.*/'&',/" input.txt
> >>
> >>
> >
> > Or, more sensibly:
> >
> > awk '{print "\047"$0"\047"}' ...
>
> You missed the comma, by the way.
> >
> > Tip: Avoid cryptic, meaningless tools like "sed" (and friends).
> >
>
> How is 'print "\047"$0"\047" less cryptic than the above sed line?
>
> Sorry, I don't want to start an awk V sed flame war, but let's face it, that
> so-called tip IS flame-bait.
>
> Andrew

I think he was attempting a joke.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Loki Harfagr on
Fri, 23 Jul 2010 14:03:41 -0400, Barry Margolin did cat :

> In article <i2cf5j$982$1(a)south.jnrs.ja.net>,
> Andrew McDermott <a.p.mcdermott(a)NOSPAM-rl.ac.uk> wrote:
>
>> Kenny McCormack wrote:
>>
>> > In article <MP6dneh2BdV5CdTRnZ2dnUVZ_sydnZ2d(a)giganews.com>, hehe2046
>> > <user(a)compgroups.net/> wrote:
>> >>I would say: sed -i "s/.*/'&',/" input.txt
>> >>
>> >>
>> >>
>> > Or, more sensibly:
>> >
>> > awk '{print "\047"$0"\047"}' ...
>>
>> You missed the comma, by the way.
>> >
>> > Tip: Avoid cryptic, meaningless tools like "sed" (and friends).
>> >
>> >
>> How is 'print "\047"$0"\047" less cryptic than the above sed line?
>>
>> Sorry, I don't want to start an awk V sed flame war, but let's face it,
>> that so-called tip IS flame-bait.
>>
>> Andrew
>
> I think he was attempting a joke.

Most probably, after all he he really wanted to avoid cryptic stuff
he'd certainly would have given a simple plainest überclear shell
solution, for instance:
------------
$ cat blobber

exec 5<&0 ### lets say stdin somewhere else
exec < "${1}" ### stdin becomes the file
while read l
do
echo "'${l}',"
done
exec 0<&5 5<&- ### stdin back to normality
------------

or, keeping the first idea of "missing the comma" even
more 'readablest' toolbox solution:
------------
yes "'" | head -n $(wc -l yourfile | cut -f 1 -d" ")|tee - |paste -d "" - yourfile -
------------

but maybe "missing the comma" would be like 'jumping the shark' ;-)

(forgive me for what the heatwave's doing to my inner circuits ,-)
From: Loki Harfagr on
Sat, 24 Jul 2010 09:13:59 +0000, Loki Harfagr did cat :
....
> exec 5<&0 ### lets say stdin somewhere else exec < "${1}"

just in case, it is probably better to avoid using that special number 5
can't remember the details but it was (at a time/forever/wot ?) used by
some bash in some situations for forks redirs, or something akin,
hum, gotta get back to read about this as I realize I've all
forgotten about these corner cases :-)
From: Kenny McCormack on
In article <i2cf5j$982$1(a)south.jnrs.ja.net>,
Andrew McDermott <a.p.mcdermott(a)rl.ac.uk> wrote:
>Kenny McCormack wrote:
>
>> In article <MP6dneh2BdV5CdTRnZ2dnUVZ_sydnZ2d(a)giganews.com>,
>> hehe2046 <user(a)compgroups.net/> wrote:
>>>I would say: sed -i "s/.*/'&',/" input.txt
>>>
>>>
>>
>> Or, more sensibly:
>>
>> awk '{print "\047"$0"\047"}' ...
>
>You missed the comma, by the way.
>>
>> Tip: Avoid cryptic, meaningless tools like "sed" (and friends).
>>
>
>How is 'print "\047"$0"\047" less cryptic than the above sed line?
>
>Sorry, I don't want to start an awk V sed flame war, but let's face it, that
>so-called tip IS flame-bait.
>
>Andrew

My point was that it is better to learn to use a tool that is likely to
help you more down the line. I learned AWK pretty much as my first
tool, and never really bothered with sed/join/comm/tr/etc. I think we
do people a disservice by giving them sed/join/comm/tr/etc solutions.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch [sic] revelations of the childhood
traumas of the participants...

First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: GNU Parallel 20100722 released
Next: ulimit question