Re: bash help please

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 05/30/04


Date: Sun, 30 May 2004 08:08:35 GMT

On Sun, 30 May 2004 06:31:06 GMT, Alan Connor <zzzzzz@xxx.yyy> wrote:
>
>
> On Sun, 30 May 2004 06:01:53 GMT, Dave Brown <dhbrown@hobbes.dhbrown.net> wrote:
>>
>>
>> In article <%wytc.14110$be.430@newsread2.news.pas.earthlink.net>,
>> Alan Connor wrote:
>>> On Fri, 28 May 2004 02:46:12 GMT, SuperDaemon <Super@DiskAndExecutionMonitor.biz> wrote:
>>>>
>>>> I know there are some good fellows around here who are well versed in using
>>>> "grep", "sed" and "regexpr".
>>>>
>>>> I have large data file with entries like:
>>>> ...
>>>
>>> ed -s file <<XXXX
>>> g/^[0-1][0-9]\/[0-3][0-9]\/[0-9][0-9]/s/$/,/
>>> g/.*([0-9][0-9]*%)/s/$/,/
>>> g/^[0-1][0-9]\/[0-3][0-9]\/[0-9][0-9]/.,+2j
>>> .
>>> wq
>>> XXXX
>>
>> And, of course, you can avoid the "leaning toothpicks", /\/\//,
>> by using a different pattern delimiter, eg:
>> g|^[0-1][0-9]/[0-3][0-9]/[0-9][0-9]|s|$|,|
>>
>>
>> But the perl solution by John Krahn was the neatest!
>>
>
> No. It's the stupidest solution. Using perl for something
> like this is like using a tactical nuke to kill houseflies.
>
> It works no better than the ed solution and requires an
> application and libraries ten thousand times the size
> of ed. Can't imagine anything less efficient.
>
> It's like a guy sitting around while hundreds of slaves
> build his house and saying to his buddy: "Gee, building
> a house is easier than I thought."
>
> (and fails to notice that he has become fat and weak)
>
> The best solution would be to just open the file in ed
> and enter:
>
> g/[%/]/s/$/,/
> g/\//.,+2j

[post got truncated by server -- gotta remember to comment
out scripts on the Usenet]

# g/[%/]/s/$/,/
# g/\//.,+2j
# .
# wq

A lost of systems don't have perl, and portability is always
a consideration in such matters, for another thing.

AC



Relevant Pages

  • Re: Printing to a file
    ... > Charles Clarkson, Randall Schwartz, and John Krahn (I'm only naming three. ... use Perl; ...
    (perl.beginners)
  • Re: bash help please
    ... It's the stupidest solution. ... Using perl for something ... >> like this is like using a tactical nuke to kill houseflies. ...
    (comp.os.linux.misc)