chnaging a specific column in a specific row with for loop

38 Views Asked by At

I have a file with following content

### beginning of executable commands

### load the necessary module files

module load GCC/11.3.0 OpenMPI/4.1.4 CP2K/9.1

### your program goes here (a.out is an example)
$MPIEXEC $FLAGS_MPI_BATCH cp2k.popt -i nvt_10.inp -o nvt_10.out

I want to change "nvt_10.inp" in iterative way such that the number changes only. Like nvt_20.inp, nvt_30.inp ......

Please help me to get a solution of it.

I tried with awk but not able to get it.

1

There are 1 best solutions below

1
Hai Vu On

Use the seq command to generate a sequence of numbers. This example will generate numbers from 10 to 100, increase 10 each time:

for number in $(seq 10 10 100)
do
    echo $MPIEXEC $FLAGS_MPI_BATCH cp2k.popt -i nvt_${number}.inp -o nvt_${number}.out
done

Run it, if you are satisfied with the outcome, you can remove the echo to make it executing for real.