i have a text file that contain four columns of data,I want to modify only 4th column with some conditions.
condition : The 4th column
of the input file contains negative and positive values. First of all I want to keep the negative values of 4th column
if it falls within the range -1.249582196275393240e-02
and -2.100552742679913983e-02
and similarly i want to keep the positive values of the 4th column if it falls within the range 1.381056887718538353e-04
and 2.346095085764924595e-04
.
However remaining negative values of the 4th column
should be replaced randomly and that random number should fall in the range -1.145493471994996071e-03
and -1.8445493471994996071e-03
and in the similar way the remaining positive values should fall randomly within the range 1.531056887718538353e-06
and 1.956056887718538353e-06
.
My input
file is
2.60000038 2.99699998 -0.00000000 -1.249582196275393240e-02
2.70000076 2.99699998 -0.00000000 -2.296202816069126129e-02
2.80000114 2.99699998 -0.00000000 -2.527230263998111234e-02
2.89999962 2.99699998 -0.00000000 -2.100552742679913983e-02
2.89999962 2.99699998 -0.00000000 -2.150552742679913983e-01
2.89999962 2.99699998 -5.00000000 -2.190552742679913983e-01
2.89999962 2.99699998 -900000000 -2.190552742679913983e-03
0.500000000 2.99699998 -1.14950405E-09 1.381056887718538353e-04
0.600000381 2.99699998 -1.66670497E-10 2.346095085764924595e-04
0.700000763 2.99699998 -9.37441375E-11 2.136244050537546566e-04
0.800000763 2.99699998 -9.37441375E-11 1.126244050537546566e-04
0.700000763 2.99699998 -9.37441375E-11 1.136244050537546566e-04
0.700000763 2.99699998 -9.37441375E-11 2.136244050537546566e-03
the below mentioned three lines of the input file
2.89999962 2.99699998 -0.00000000 -2.150552742679913983e-01
2.89999962 2.99699998 -5.00000000 -2.190552742679913983e-01
2.89999962 2.99699998 -900000000 -2.190552742679913983e-03
should be replaced by
2.89999962 2.99699998 -0.00000000 -1.149552522674912181e-03
2.89999962 2.99699998 -5.00000000 -1.141552612675913281e-03
2.89999962 2.99699998 -900000000 -1.346552142676911382e-03
Additionally, these three lines of the input file
0.800000763 2.99699998 -9.37441375E-11 1.126244050537546566e-04
0.700000763 2.99699998 -9.37441375E-11 1.136244050537546566e-04
0.700000763 2.99699998 -9.37441375E-11 2.136244050537546566e-03
should be replaced by
0.800000763 2.99699998 -9.37441375E-11 1.561056887718538353e-06
0.700000763 2.99699998 -9.37441375E-11 1.621056887718538353e-06
0.700000763 2.99699998 -9.37441375E-11 1.506244050537546566e-06
so my overall output should be
2.60000038 2.99699998 -0.00000000 -1.249582196275393240e-02
2.70000076 2.99699998 -0.00000000 -2.296202816069126129e-02
2.80000114 2.99699998 -0.00000000 -2.527230263998111234e-02
2.89999962 2.99699998 -0.00000000 -2.100552742679913983e-02
2.89999962 2.99699998 -0.00000000 -1.149552522674912181e-03
2.89999962 2.99699998 -5.00000000 -1.141552612675913281e-03
2.89999962 2.99699998 -900000000 -1.346552142676911382e-03
0.500000000 2.99699998 -1.14950405E-09 1.381056887718538353e-04
0.600000381 2.99699998 -1.66670497E-10 2.346095085764924595e-04
0.700000763 2.99699998 -9.37441375E-11 2.136244050537546566e-04
0.800000763 2.99699998 -9.37441375E-11 1.561056887718538353e-06
0.700000763 2.99699998 -9.37441375E-11 1.621056887718538353e-06
0.700000763 2.99699998 -9.37441375E-11 1.506244050537546566e-06
i tried
awk '{for(i=1;i<=NF;i++)if($4==-1.249582196275393240e-02 && -2.100552742679913983e-02)$i=" "}1' input
However, i am facing some problem in solving this.I hope experts may help me.Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire