is it possible to change a particular cell using bash?
09:04 18 Nov 2025

I have a file that consists of multiple tables of the same format. I want to change the particular cell in each table. Can I do it using bash and without touching the structure of the file? I only want to modify the value in corresponding cell. I tried the following code. However, it changes all the 0 values on line29 instead of the only the value on specified column. Also, the format changes where the values are changed. I tried to keep the format as it is by arranging the spaces manually but this is not convenient and I do not know if this would work for the rest of the file.

#!/bin/bash

input="modify_trial.int"
output="modify_trial_modified7.int"

awk '
BEGIN {
    line_in_block = 0
}

{
    line_in_block++
    raw[line_in_block] = $0  

    for (i=1; i<=NF; i++) {
        field[line_in_block, i] = $i
    }

    # End of block (33 lines)
    if (line_in_block == 33) {

        old = field[30,6]
        new = old - 20

        gsub(old, new, raw[30])

        old24 = field[27,4]
        new25col4 = old24 / 2
        gsub(field[28,4], new25col4, raw[28])

        old26 = field[29,6]
        new26col6 = (old26 - 10) * (-1)

        gsub(field[29,6], new26col6, raw[29])


        old26col5 = field[29,5]
        new26col5 = old26col5 - 1
        field[29,5] = sprintf("%.4f", new26col5)
        new_line = sprintf("%-5s %10.4f %1d %9.4f %1d %8.4f %1d %4d %4d %4d",
                  field[29,1], field[29,2], field[29,3], field[29,4], field[29,5],
                  field[29,6], field[29,7], field[29,8], field[29,9], field[29,10])
        
        raw[26] = new_line

        gsub(field[28,6], "0.0000", raw[28])

        # Reset everything for next block
        delete raw
        delete field
        line_in_block = 0
    }
    }
' "$input" > "$output"
bash shell