This is a follow-up question from Modify text column based on the column before it
I wanna change the starting index of the line processing, say start from the third line. I notice that in order for perl to use the variable in shell, I must export the variable and use $ENV{} in perl, see:
#!/bin/bash
t=3
export t
perl -lane '$F[3] += sin($F[2]/10 * 4 * atan2 1, 1) if($ENV{t} .. 4);
print "@F"
'test.txt > test_new.txt
Here test.txt is merely the same in the previous question:
A 0.016333 0.003203 0.472723
A 0.016333 0.035228 0.472723
B 0.016333 0.067253 0.472723
B 0.016333 0.099278 0.472723
C 0.016333 0.131303 0.472723
C 0.016333 0.163328 0.472723
However, the $ENV{t} does not work at all: the line processing still starts from the first line. Maybe in IF statement the usage is different??
Aucun commentaire:
Enregistrer un commentaire