Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Process two...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 10 Topic 2151 of 2317
Post > Topic >>

Re: Process two files simultaneously

by "Luuk" <luuk@[EMAIL PROTECTED] > Feb 7, 2008 at 10:27 AM

"Ed Morton" <morton@[EMAIL PROTECTED]
> schreef in bericht 
news:47AAA91F.9010208@[EMAIL PROTECTED]
>
>
> On 2/6/2008 8:35 PM, Combatwombat wrote:
>> ##ALERT!!!### Noobie struggling with Awk
>>

> a) "getline" is almost certainly the wrong approach.
> b) concatenating both files and setting awk variables with their names
is 
> also
> almost certainly the wrong approach.
> c) let's start with this:
>
> awk '{print FILENAME, $0}' old.csv replacement.csv > newfile
>
> so you can see how you can run an awk script on multiple input files and

> we'll
> take it from there.
>
> Ed.
>

awk '{ print FILENAME, FNR, NR }' old.csv replacement.csv

will output
old.csv 1 1
old.csv 2 2
old.csv 3.3
replacement.csv 1 4
replacement.csv 2 5
replacement.csv 3 6

so, you can check in your script which inputfile you're reading from bye 
comparing FNR and NR

so, i would start with:

awk 'NR=FNR{ repl[$1]=substr($0,length($1+1)); next; } { rest of your 
script, which checks if repl[] things are contained in file old.csv }' 
replacement.csv old.csv
 




 10 Posts in Topic:
Process two files simultaneously
Combatwombat <combatwo  2008-02-07 15:35:34 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 00:45:51 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-07 20:45:48 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 08:01:22 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-08 03:46:46 
Re: Process two files simultaneously
Janis Papanagnou <Jani  2008-02-07 19:35:34 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-08 09:53:59 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 14:59:43 
Re: Process two files simultaneously
"Luuk" <luuk  2008-02-07 10:27:08 
Re: Process two files simultaneously
Janis <janis_papanagno  2008-02-07 04:44:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 0:58:13 CDT 2008.