Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two problems

Status
Not open for further replies.

tonivm

Technical User
Mar 2, 2006
64
ES
hi everybody:
I just try to do a script that transform a format file, and

The datafile are such :

98,1009.4,20.9,66,14.3
149,1003.4,21.1,63,13.8
221,995.1,20.9,64,13.9
278,988.6,20.5,69,14.6
.......................
.......................

and after to do mathematics, the script is:

for i in `ls *.txt`
do
fitxer=`echo $i | cut -c 1-8`
sed '1,3d' $i > $fitxer.t;
LC_ALL=en_DK gawk 'BEGIN {OFS =","};{print $4, $5, $6, $7, $8}' $fitxer.t > $fitxer.fmf

done

for i in `ls *.fmf`
do
fitxer=`echo $i | cut -c 1-8`
LC_ALL=en_DK gawk 'BEGIN{FS =",";OFS =","};
{Pv=6.112*10^(7.5*$6/($6+237.3));
HA=Pv/(461.5*($6+273.15))*1000};
rho=(6.112*10^(7.5*$6/(273.7+$8))/(($6+273.15)*461.5))*1000;
{print $1, $2, $3, $4, $5, HA, rho}' $i > $fitxer.dat
done
rm -f *.t;
rm -f *.fmf;

exit 0


i have the files like:

98,1009.4,20.9,66,14.3
98,1009.4,20.9,66,14.3,0.0484853,0.0484853
149,1003.4,21.1,63,13.8
149,1003.4,21.1,63,13.8,0.0484853,0.0484853
221,995.1,20.9,64,13.9
221,995.1,20.9,64,13.9,0.0484853,0.0484853
278,988.6,20.5,69,14.6
278,988.6,20.5,69,14.6,0.0484853,0.0484853
.......................
.......................

and i don't know why repeat each row two times, and i'd like to have only the row with my calculations.
how could i do it?.
thanks in advance.
best regards to everybody.
 
LC_ALL=en_DK gawk '
BEGIN{FS =",";OFS =","}
{ Pv=6.112*10^(7.5*$6/($6+237.3))
HA=Pv/(461.5*($6+273.15))*1000[!])[/!]
rho=(6.112*10^(7.5*$6/(273.7+$8))/(($6+273.15)*461.5))*1000
[highlight] [/highlight]print $1, $2, $3, $4, $5, HA, rho
}' $i > $fitxer.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top