Re (2): HOW2 call a function from inside awk ?

Re (2): HOW2 call a function from inside awk ?

Post by no-toppos » Mon, 14 Sep 2009 18:56:53



Well:
DV | gawk ' BEGIN { FS =")"}
/kdeinit/{D++; V=1; print D "," V $4 };
!/kdeinit/{ V++; print D "," V $3 };
END {print D "," V}' | gawk '/mc/' | sed s/"---mc("/" "/g > /usr/local/bin/dv

Plus a few more steps gives me:
...
3,1 = /mnt/cdrom/Inet/GroupsIndx/OnwNewDebug/otmp
4,5 = /usr/local/bin
..
So if a job for "otmp" or related arrives, I know
that desktop4, VT5 is where to go.
Except that the first char/s "4" is actually false and
needs to be translated, easily by: ` tr 1234 4123`

Now to have to split off this 1st char of the line and
translate it and put it back, is a problem for me.

And this char was generated in the awk script at:
`D++` so if I could have done:
D++; #step D for next sub-tree
print ` D | tr 1234 4123` "," V $4 # the correct D
or equivalent it would be good.
But understandably you can't do that.

What I've learnt from this exercise is that all this stuff
is crap. It's like before 'structured programming' was
introduced, you hacked in BASIC to get an unmaintainable
mess. "tr 1234 4123" is deceptively cute. But by
hiding the fact whether a variable is a string or a number,
the virtual/smart-arse/bluff where variables are
automagically converted between strings and numbers,
just gets you into trouble as the task expands beyond
triviality.

You can't by-pass the lessons learned 40 years ago,
any more than the economic realities from Moses days
that you can't take > 75% mortage on your house to
buy beer.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by pgas » Mon, 14 Sep 2009 20:49:56


Well, hopefully Ed has learnt not to try to help a troll.

It's hard to quit this habit, because you always feel someone
will believe their crap. Hopefully this one seems ignorant enough
to not be able to do too many damage.

--
pgas @ SDF Public Access UNIX System - http://www.yqcomputer.com/

 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by Ted Davi » Mon, 14 Sep 2009 23:09:16


If you don't like the language, don't use it. And don't keep bothering
those of us who do like it and find it useful ... just go away - you are
definite killfile material here.

--

T.E.D. ( XXXX@XXXXX.COM )
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by pk » Mon, 14 Sep 2009 23:25:51


Maybe that gets *you* into trouble, and judging by your rants here, it seems
it definitely does.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by Ed Morto » Tue, 15 Sep 2009 00:07:24


> kdeinit/{D++; V=1; print D "," V $4 };> > /kdeinit/{ V++; print D ," V $3>};
> ND {print D "," V}' | gawk '/mc/' | sed s/"---mc("/> "/g > /usr/local/bi>/d>
>
> Plus a few more steps gives>me:
>>...
> 3,1 = /mnt/cdrom/Inet/GroupsIndx/OnwNewDebug/>tmp
> 4,5 = /usr/local>bin
> So if a job for "otmp" or related arrives, I >now
> that desktop4, VT5 is where to>go.
> Except that the first char/s "4" is actually false>and
> eeds to be translated, easily by: ` tr 234 >41>3`
>
> Now to have to split off this 1st char of the li>e and
> translate it and put it back, is a problem f>r >e.
>
> And this char was generated in the awk scri>t at:
> `D++` so if I could hav> done:
> D++; #step D for next s>b-tree
> print ` D | r 1234 123` "," V $4 # the c>rrect D
> r equivalent it would>be good.
> But understandably you can't>do>that.
>
> What I've learnt from this exercise is that all t>is stuff
> is crap. t's like before 'structured program>ing' was
> introduced, you hacked in BASIC to get an unmai>tainable
> mess. tr 1234 123" is deceptively c>te. But by
> hiding the fact whether a variable is a string o> a number,
> the virtual/smart-arse/bluff where va>iables are
> automagically converted between strings a>d numbers,
> just gets you into trouble as the task exp>nds beyond
> >ri>iality.
>
> You can't by-pass the lessons learned 40>years ago,
> any more than the economic realities from>Moses days
> that yo> can't take > 75% mortage on yo>r house to
> buy beer.

I surrender. I would correct your script and show you how to do what
you want in awk, but doubtless you'd ignore that as you have every
other point. I have absolutely no idea what the point was of you
posting your questions but I apologize to the group for having wasted
everyone's time trying to help you.

Ed.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by Loki Harfa » Tue, 15 Sep 2009 00:44:07

Sun, 13 Sep 2009 08:07:24 -0700, Ed Morton did cat:


Nice, I didn't know that Moses had positions about the
'uncannyness' of free market ;-)


that's probably the safe way with him :-)


like before, he's trying and build the perfect O.D.E. using every
piece of the toolbox in the most unreal way, it's a long
way to the top but major groups of dev' are already trembling
as when his ODE will be deployed it'll rule the world.
At his spare time he uses to sing and draw wicam stuff
while pretending they're Feynman diagrams on steroids.


Don't apologize, your answers to his awk "problems"
were instructive to me (and I guess a few others), that was
nice work and it's never lost for everyone :-)

Besides, as I posted at your "awk -v nr=9837 " post it was
more fun to keep him posting a bit more, that bit's done
now the door opend then closed.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by no-toppos » Tue, 15 Sep 2009 09:06:56


I wonder how it looks if I just 'bounce back' the "=A0" etc. mime *** ?


Ok.

Ok
Perhaps you don't know the extremely simple
tr 4123 1234
which is taylor made for my requirements to
translate "4" to "1" & ..."3" to "4".
Where awk does:
print D "," V $3
if it could 'print'
what you would understand by: (echo D | tr 4123 1234)
instead of: D
THEN I'd have what I need.
But I still believe these little Unix-gotcha utilities
are 'worse' than programming in original-BASIC
Thanks,

== Chris Glur.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by despe » Tue, 15 Sep 2009 10:01:03


XXXX@XXXXX.COM writes:


I write a lot of utilities at work.

I've come to view the shell/awk unholy combo as my enemy.

They're fine for one or 2 lines, but as the thing starts to grow
you invariably start running into barriers.

I mostly start with perl now and I haven't regretted the decision yet
and I've written a load of stuff. Recently I took a pretty large
set of tools written in C and reduced them to a lot less lines of
code in Perl, and they do more now.
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by Ted Davi » Tue, 15 Sep 2009 10:24:51


You'd *love* my script for widening lines in (some) binary BMP image
files. It's fairly long, but still easy to write and maintain because it's
in gawk.

--

T.E.D. ( XXXX@XXXXX.COM )
 
 
 

Re (2): HOW2 call a function from inside awk ?

Post by John Hasle » Tue, 15 Sep 2009 10:36:55

despen writes:

Um, that is _exactly_ what they were intended for, though I'd make that
one to twenty lines.
--
John "Have written a 1000 line program in POSIX shell and lived" Hasler
XXXX@XXXXX.COM
Dancing Horse Hill
Elmwood, WI USA