Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #1282

Re: Re (3): HOW2 pass args to awk?

From Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID>
Subject Re: Re (3): HOW2 pass args to awk?
Newsgroups comp.os.linux.misc, comp.lang.awk
References <pan.2011.05.29.17.46.08@thedarkdesign.free.fr.INVALID> <iruv09$40j$1@dont-email.me>
Message-ID <pan.2011.05.30.09.01.34@thedarkdesign.free.fr.INVALID> (permalink)
Date 2011-05-30 09:01 +0000
Organization Guest of ProXad - France

Cross-posted to 2 groups.

Show all headers | View raw


Mon, 30 May 2011 02:22:06 +0000, no.top.post did cat :

> In article <pan.2011.05.29.17.46.08@thedarkdesign.free.fr.INVALID>, Loki
> Harfagr <l0k1@thedarkdesign.free.fr.INVALID> wrote:
> 
>> Sun, 29 May 2011 15:56:37 +0000, no.top.post did cat :
>> 
>> > In article <slrnit4oho.5u2.bill@lat.localnet>, Bill Marcum
>> > <bill@lat.localnet> wrote:
>> > 
>> >> ["Followup-To:" header set to comp.os.linux.misc.] On 2011-05-17,
>> >> no.top.post@gmail.com <no.top.post@gmail.com> wrote:
>> >> > I had suspected that ARGV could do it. But it fails.  Are you
>> >> > fooling with me?
>> >> >    gawk '
>> >> >        BEGIN {
>> >> >            arg1 = ARGV[1]
>> >> >            arg2 = ARGV[2]
>> >> > print "arg1=" arg1  <--- 'arg1' is 'empty'/uninitialised }'
>> >> >
>> >> > exit
>> >> > /arg1/&&/arg2/{print FILENAME ":" $0}'\
>> >> >  `find /mnt/p11/PhysicalSpace/DirTest  -type f`
>> >> >
> ---------------
> Why don't you comment on my obvious attempt to TRACE the <arg to the
> script> as being [or NOT] allocated to 'arg1', instead of going off on
> your own, prefered syntax?! --------------------

I'm not "going off on your own, prefered syntax", I was just trying to
help you and us to reach a point where what you post would be readable and
understandable (On a technical point of view that is, I won't try and
do anything about your Tourette and the dried mushrooms).

So, the answer to that question:
" Why don't you comment on my obvious attempt to TRACE the <arg
...
"
is that I wouldn't comment something that was not obvious at all to
me as I really couldn't find a reason why you posted that snippet of
non code coming out from the blue and going nowhere.


>> >> In the above script, the gawk command ends at  }' . It has no
>> >> arguments. "exit" is interpreted as a shell command, and the lines
>> >> after it are ignored.
>> > Yes that's how I intended, except that IT is a script and gets CALLED
>> > WITH ARGS. So I want to call the script with 2 args:
>> >    `script dog fish`
>> > and confirm that `print "arg1=" arg1` has got 'dog'.
>> > 
>> > Isn't it obvious that I've pasted my actual script, that I've been
>> > hacking ?
>> > 
>> > The output of: ./<theScript> dog
>> >  is: 'arg1='
>> > 
>> > So would that pass 'dog' to the <awk operation> as required ?
>> > 
>> > == TIA
>> > 
>> > PS I'm posting from the 3rd world & can only post on weekends.
>> 
>> Understood, some local production to test sure can make some difficult
>> awakenings
>> 
>> Still not sure of what you exactly mean to actually do but I think that
>> I now have an idea of what you're trying and write in your posts so
>> here's a short test on sample files that may help you and the group to
>> find a common language platform, at least if you can say and explain if
>> (and why) it is not what you want ;-)
>> 
>> I started with a "mother" file:
>> ---------
>> $ cat animalz
>> Class: dog fish cow
>> Class: cow mouse
>> Class: flea market
>> Order: flea dog
>> Order: mouse dog
>> Class: fly dog
>> Class: flea dog
>> Order: cow dog
>> 
>> Noise: blurb doubt
>> ---------
>> 
>> and made a bunch of bench files from it: ---------
>> $ split -l 1 animalz
>> ---------
>> 
>> So, if that bench is not related to your question please then tell how
>> and, better yet, provide a short bench env.
>> 
>> If the bench is "admissible", then this could well represent a starting
>> track for an answer to your question :-)
> No! My question is "HOW2 pass args to awk?" !!

That's the part of your initial post that was quite understandable, since
then you had several various answers, including a few about the ARGV stuff
and, though I thought theses answers addressed your question you then started
roaring like a Vulcan forcefed with powerpoint presentations.
So I supposed you still had a problem with your "search script" and I
simply asked if your question could be simplified and exampled on  a very
small set of bench stuff and hence proposed a first version of
bench that you would "admit" or "extend" or propose a better one.

The question until now, for me, is that you're requesting every one to
use some specific words in some sentences in order to write a paragraph
but I just suggested that we all start with being in tune about what the
final paragraph would express.


> It is inappropriate to
> change the format of the rest of the script, to your prefered style.
> We know there are countless styles which will achieve the goal. Please
> comment on the previously suggested syntax of
>     arg1 = ARGV[1]

I'd say others already have done so, and as for myself I won't comment
about the style on an operation that I have no idea what its goal is.
You may have some reasons to insist on using a corkscrew to file this
nail but at this point I still don't understand what are all these
spoons for and where do they joint with the yellow turtle in the middle
of the rack.

> It seems that there are 2 candidate syntaxes, and every clown is pushing
> HIS favourite.
> Did YOU understand my attempt to TRACE the successful conversion of the
> <arg passed to the script>, inside the script, before it's used in the
> regex-matching?

No, first I didn't recognize that you were attempting that and then
I still have no idea about (see supra...)

> Is that unsound ?
> Do YOU realise that I want to call a script with [initially] one arg.

No. Nor any idea where I would have found that hint, but I may have
missed it somewhere in the tons of strange snippets ;-)

> Currently I just call different scripts for each <class>. This 'project'
> is amazingly simple, yet massively powerfull, to help <find the
> real-space-location of your paper docus, since the dir-tree is perfectly
> isomorphic to real-space.
>> ---------
>> $ find . -type f -name 'x*' | \
>> xargs awk -v arg1="Class:" \
>> -v arg2="cow" -v arg3="mouse"\
>>  '($0~arg1 && ( $0~arg2 || $0~arg3))\
>>  {print FILENAME,FNR,$0}'
>>  
>> ../xab 1 Class: cow mouse
>> ../xaa 1 Class: dog fish cow
>> ---------
>> .
> Do you realise that my 'code' is in a bash-script ?

well, do you realize that so is mine ? Or so could it?
It is called directly in a shell but a shell is a script is a rose
(to most extents at least, we'll avoid any extensive discussion on
environments at this point of the thread as it already is quite
painful enough to read)

> 
> ==TIA.

So, from the tiny bench I proposed are we going somewhere?
Is that close enough to you problem? If not could you post a
bench that would be usable and understandable enough that would do
the stuff you want and then the group could concentrate to 
understand enough your question and your addressing so we'll
have a chance to try any complementary answer about style/args/whatever.

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: HOW2 pass args to awk? no.top.post@gmail.com - 2011-05-17 06:27 +0000
  Re: HOW2 pass args to awk? Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-05-17 09:12 +0200
    Re: HOW2 pass args to awk? Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> - 2011-05-17 00:21 -0700
      Re: HOW2 pass args to awk? Harold Stevens <wookie@jimbo.localdomain> - 2011-05-17 09:17 -0500
      Re: HOW2 pass args to awk? Aragorn <aragorn@chatfactory.invalid> - 2011-05-17 17:36 +0200
    Re (2): HOW2 pass args to awk? no.top.post@gmail.com - 2011-05-29 15:56 +0000
      Re: Re (2): HOW2 pass args to awk? Bill Marcum <bill@lat.localnet> - 2011-05-29 13:05 -0400
        Re (3): HOW2 pass args to awk? no.top.post@gmail.com - 2011-05-30 02:22 +0000
          Re: Re (3): HOW2 pass args to awk? Aragorn <aragorn@chatfactory.invalid> - 2011-05-30 05:09 +0200
  Re: HOW2 pass args to awk? Bill Marcum <bill@lat.localnet> - 2011-05-17 07:55 -0400
    Re (2): HOW2 pass args to awk? no.top.post@gmail.com - 2011-05-29 15:56 +0000
      Re: Re (2): HOW2 pass args to awk? Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-05-29 17:46 +0000
        Re (3): HOW2 pass args to awk? no.top.post@gmail.com - 2011-05-30 02:22 +0000
          Re: Re (3): HOW2 pass args to awk? Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-05-30 09:01 +0000
          Re: Re (3): HOW2 pass args to awk? and more Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-05-31 11:05 +0000
            Re: Re (3): HOW2 pass args to awk? and more Ralf Fassel <ralfixx@gmx.de> - 2011-05-31 14:35 +0200
              Re: Re (3): HOW2 pass args to awk? and more Ed Morton <mortonspam@gmail.com> - 2011-05-31 07:56 -0500
              Re: Re (3): HOW2 pass args to awk? and more Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-05-31 14:14 +0000
                Re: Re (3): HOW2 pass args to awk? and more Ralf Fassel <ralfixx@gmx.de> - 2011-06-01 10:41 +0200
              Re (4): HOW2 pass args to awk? and more no.top.post@gmail.com - 2011-06-06 10:26 +0000
                Re: Re (4): HOW2 pass args to awk? and more Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-06-06 14:01 +0000
            Re (4): HOW2 pass args to awk? and more no.top.post@gmail.com - 2011-06-06 04:58 +0000

csiph-web