РЕДАКТИРОВАТЬ2: Поскольку OP снова немного изменила требование, добавьте сюда новый код.
awk -v line="124" -v diff="6" '(FNR==line || FNR==(line+diff)) && (FNR>=124 && FNR<=160){$2=(($2*9.88)/100)+$2;diff+=6} 1' Input_file
РЕДАКТИРОВАТЬ: В соответствии с OP, OP хочет захватывать только строки от 124 до 160, которые полностью разделены на 2.
awk 'FNR%2==0 && (FNR>=124 && FNR<=160){$2=(($2*9.88)/100)+$2} 1'
Следование awk
может помочь вам в этом.
awk 'FNR%2==0{$2=(($2*9.88)/100)+$2} 1' Input_file
В случае, если вы хотите сохранить выходные данные в самом файле Input_file, добавьте > temp_file && mv temp_file Input_file
к вышеуказанному коду.
Объяснение вышеприведенного кода:
awk '
FNR%2==0{ ##Checking condition if line number is divided by 2 is fully divided by 2 if this is TRUE then do following.
$2=(($2*9.88)/100)+$2}##Re-creating $2 here by doing multiplication with 9.88 nd dividing it by 100 to get its 9.88% and adding itself to it.
1 ##Mentioning 1 here, awk works on method of condition then action, so making condition TRUE here and not mentioning any action so by default print of current will happen.
' Input_file ##Mentioning Input_file name here.