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


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

Re (2): Can awk use `grep`?

From no.top.post@gmail.com
Newsgroups comp.lang.awk, comp.os.linux.misc
Subject Re (2): Can awk use `grep`?
Date 2011-06-26 18:03 +0000
Organization A noiseless patient Spider
Message-ID <iu7sa1$3un$1@dont-email.me> (permalink)
References <iu7414$bnp$1@speranza.aioe.org>

Cross-posted to 2 groups.

Show all headers | View raw


In article <iu7414$bnp$1@speranza.aioe.org>, pk <pk@pk.invalid> wrote: 

> On Sun, 26 Jun 2011 10:36:52 +0000 (UTC)
> no.top.post@gmail.com wrote:
> 
> > I've got two inputs.  Input1 looks like:-
> > 3
> > 5
> > 7
> > 9
> > 
> > Input2 looks like:-
> > 9  pathC
> > 3  pathB
> > 7  pathA
> > 
> > I want to get:-
> > 3  pathB
> > 5
> > 7  pathA
> > 9  pathC
> 
> 
> With awk, the usual way to do that is:
> 
> awk 'NR==FNR{a[$1]=$2;next}{print $0, a[$0]}' Input2 Input1
> 
Thanks, a superficial test looks ok.
My real problem is more complex than I described,
and I'd like Input2 Input1 to be 2 functions: PT DV.
So I'm guessing that I'd just use:
`PT' `DV`

I too used to be guilty of one-lineism when younger.
Too bad for other maintainers - I'm not paid to be a tutor.
{   // the matching conditions are
a[$1]  // the 1st field of an entity bound to 'a'
=$2  // equals the 2nd fiel of the input line
;    // and also  ??
}   // end of matching conditions
{  // start action for matching condition/s
print $0   // print 1st field of the input line
,   // and
print 1st field  <related to> the 'a' entity
}'  // end of <awk> except for input args
Input2 Input1  // input 2 files in unknown sequence.

`awk` is a DEVIL !!

Back to comp.os.linux.misc | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re (2): Can awk use `grep`? no.top.post@gmail.com - 2011-06-26 18:03 +0000
  Re: Re (2): Can awk use `grep`? Bill Marcum <bill@lat.localnet> - 2011-06-27 01:55 -0400
    Re: Re (2): Can awk use `grep`? Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-06-27 12:51 +0100
      Re: Re (2): Can awk use `grep`? gazelle@shell.xmission.com (Kenny McCormack) - 2011-06-27 12:18 +0000
        Re: Re (2): Can awk use `grep`? Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2011-06-28 13:30 +0100
    Re (3): Can awk use `grep`? no.top.post@gmail.com - 2011-06-28 03:24 +0000
  Re: Re (2): Can awk use `grep`? Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2011-06-27 07:18 +0000
    Re: Re (2): Can awk use `grep`? Janis Papanagnou <janis_papanagnou@hotmail.com> - 2011-06-27 22:02 +0200
    Re (3): Can awk use `grep`? no.top.post@gmail.com - 2011-07-05 17:34 +0000

csiph-web