Sample Header Ad - 728x90

Add a numerical value to a variable while reading a file in bash in loop

0 votes
1 answer
180 views
I have a file with the following values. I am trying to read from the file and add 1096 to the last value and generate the output on screen. My original file looks like this. agile_prod_toolkit,30 alsv2_prod_app,30 alsv2_qa_app,15 My expected output should be as below. the third value is second value + 1096 agile_prod_toolkit,30,1126 alsv2_prod_app,30,1126 alsv2_qa_app,15,1111 What i have tried is while IFS="," read line ret;do value=$ret+1095 print $line,$ret,$value done < final_original But this does not seem to work. can someone please tell me what i am doing wrong here? The output that i am getting here when i run the above command is like this agile_prod_toolkit,30,30+1095 alsv2_prod_app,30,30+1095 alsv2_qa_app,15,15+1095
Asked by ranjit abraham (145 rep)
May 23, 2024, 12:51 AM
Last activity: May 23, 2024, 01:30 AM