From: Lal, Neeraj (Neeraj.Lal@Pfizer.com)
Date: Wed Oct 30 2002 - 13:26:13 EST
Thanks to all who responded quickly
here are the 02 script I tried and It worked it was From Bob vance & John
Kingsland
here are the scripts
Use the -v option
awk -v period=$period <pricfile.txt > oufile.txt \
'
{
ndc=substr($0,2,11);
year=substr($0,16,2);
amp=substr($0,18,11);
bp=substr($0,29,11);
drug_cat=substr($0,65,01);
print ndc period year drug_cat "0"bp "0"amp;
}
'
The other one without -v option
read period
awk <pricfile.txt > oufile.txt \
'
{
ndc=substr($0,2,11);
period=substr($0,13,1);
year=substr($0,16,2);
amp=substr($0,18,11);
bp=substr($0,29,11);
drug_cat=substr($0,65,01);
print ndc "'"$period"'" year drug_cat "0"bp "0"amp;
}
'
Thanks
Neeraj Lal
-----Original Message-----
From: Lal, Neeraj [mailto:Neeraj.Lal@Pfizer.com]
Sent: Wednesday, October 30, 2002 11:59 AM
To: 'hpux-admin@DutchWorks.nl'
Subject: [HPADM] awk question for accesing the shell variable in awk
Hi Admins
I have a awk question
here is my script
awk <pricfile.txt > oufile.txt \
'
{
ndc=substr($0,2,11);
period=substr($0,13,1);
year=substr($0,16,2);
amp=substr($0,18,11);
bp=substr($0,29,11);
drug_cat=substr($0,65,01);
print ndc period year drug_cat "0"bp "0"amp;
}
'
Thsi script is running fine and good, Now I want to change a little bit
read period
awk <pricfile.txt > oufile.txt \
'
{
ndc=substr($0,2,11);
year=substr($0,16,2);
amp=substr($0,18,11);
bp=substr($0,29,11);
drug_cat=substr($0,65,01);
print ndc period year drug_cat "0"bp "0"amp;
}
'
it is not accepting the period variable now. How can I accomplish this for
taking the period to be enetred by user and same should inserted in the
print command.
Thanks
Neeraj Lal,
Consultant
p Consumer Healthcare IS
Neeraj.Lal@Pfizer.com
Fax : 973-385-7290
-- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search) -- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:21 EDT