Gents,
Using the following script, I got the changes as desired in the output file called (spread_2611.x01.new). Complete file as input (spread_2611.x01).
Can you please have a look to my script and improve it please.
Also I would like to I get a additional selecting only the records were the changes were done, please.
Here my script and attached the data to run the script.
#!/bin/bash
read -p "First : " fsw
read -p "Last : " lsw
file="datatochange.txt"
touch $file
for swath in $(seq $fsw $lsw)
do
awk '{\
ori_line=substr($5,1,5);\
ori_point=substr($5,6,5);\
off_line=substr($1,2,5);\
off_point=substr($1,7,5);\
printf ("spread_'${swath}'.x01 %5d.00 %5d.00 %5d.00 %5d.00\n",ori_line,ori_point,off_line,off_point)}' $swath"offb1-Sx.sps" >> $file
done
awk '{F=$1;a[F];e=(F~/x01$/)?" ":z;s=$2" "$3;p=$2" "$3;r=$4" "$5;
print "s/" s "/" r "/" >> F".sed"
}END{
for(i in a){print "sed -f "i".sed "i " >>"i".new">>"changeindex"}
}' datatochange.txt
sh changeindex
awk '{print $1}' datatochange.txt | uniq > datatochange1.txt
awk '{a[$1]++ ; print $1}' datatochange1.txt | while read i
mv "$i" "$i.old" && mv "$i.new" "$i"
rm -f "$i.sed"
done
Later I will use this script to change many files at the same time.
Thanks for your help