##ALERT!!!### Noobie struggling with Awk
Hi all,
I have a problem trying to figure out how Awk can process two input
files simultaneously, as there is some reference on the web to it doing
so, eg http://www.vectorsite.net/tsawk_3.html,
but it is short on detail
and example. I am running Ubuntu 7.04 (gawk I think).
Problem: take one csv file full of data, including one field that needs
to be changed/processed on a regular, automatic, scalable basis. Take
second csv file with data in two columns; first column = field matching
data in first csv, second column = field of replacement data.
So far I have:
in Batch file:
cat old.csv replacement.csv | awk -f awkins f1="old.csv"
f2="replacement.csv" >> newfile
awkins file:
BEGIN { FS = ":" };{
if($10 =="y"||$10=="Y"){ # begin process of extraction because ALLOWSELL=y
qty=$6+$8;
if (($37 =="N"||$37=="n")&&qty<=0){
status=9
}else{ status=1;
}
{
print $1," ",$1".jpg"," ",$1," ",$2," ","url"," ",$7," ",$7," ",qty,"
",$4," ",$5," ",status,"EOREOR";
}
}
}
I couldn't fihure out how to get Awk to look at the second file; getline
worked with it , but filled the field variables with data from the
second file.
Thanks for any hints or help!


|