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 -e 'print $ENV{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 with 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??
What should I do to control which line to start?
if ( $. >= $ENV{t} )if ( $a .. $b )is always FALSE for any integer values.$.orINPUT_LINE_NUMBERTT=123 perl -lane '...... $ENV{TT} ....' foo.txtwill also work for you.