I have two columns in a file and I want to automate the summation of both values โโin a row
eg
read write
5 6
read write
10 2
read write
23 44
I then want to summarize the "read" and "write" of each line. In the end, after summing up, I find the maximum amount and put this maximum value in the file. I feel like I need to use grep -v to get rid of the column headers per row, which, as indicated in the answers, makes the code inefficient, since I am preparing the entire file for read-only rows.
I currently have this in a bash script (in a for loop, where $ x is the name of the file) to sum the columns by row
lines=`grep -v READ $x|wc -l | awk '{print $1}'`
line_num=1
arr_num=0
while [ $line_num -le $lines ]
do
arr[$arr_num]=`grep -v READ $x | sed $line_num'q;d' | awk '{print $2 + $3}'`
echo $line_num
line_num=$[$line_num+1]
arr_num=$[$arr_num+1]
done
, , 270 000+ . script , . , ?