Awk gsub between the first two regular expressions in multiple dirs.
Hello.
I create 10 directories at once with
In all of these 10 directories I copy the same file [tt]parsec.in[/tt].
I know how to print between the two regexp
Here is what I need.
I keep the zeros between the second set of [tt]begin Atom end Atom[/tt].
For directory 1,2,3....9 I need to replace the numbers between the first set of [tt]begin Atom end Atom[/tt] with let say for directory [tt]1[/tt]
for directory [tt]2[/tt]
and so fort.
I can generate the sine/cos numbers above with
And then manually copy the pairs to the respective files.
The rest of the [tt]parsec.in[/tt] file must not change.
So is there a way to to that in awk.
Any help is greatly appreciated.
Thanks
Hello.
I create 10 directories at once with
Code:
$for (( i=0; i<10; i++)) ;do mkdir $i; done
I know how to print between the two regexp
Code:
$awk ' /begin Atom/,/end Atom/ ' parsec.in
begin Atom_Coord
1.64545 1.64545 0.0
-1.78401 1.78401 0.0
end Atom_Coord
begin Atom_Coord
0.0 0.0 0.0
end Atom_Coord
I keep the zeros between the second set of [tt]begin Atom end Atom[/tt].
For directory 1,2,3....9 I need to replace the numbers between the first set of [tt]begin Atom end Atom[/tt] with let say for directory [tt]1[/tt]
Code:
sin(1) sin(1)
-cos(1) cos(1)
Code:
sin(2) sin(2)
-cos(2) cos(2)
and so fort.
I can generate the sine/cos numbers above with
Code:
awk 'BEGIN { for(i=1;i<=10;i++) printf("%2.8f %1s %2.8f \n %2.8f %1s %2.8f \n \n", sin(i),"",sin(i), -cos(i),"", cos(i) )}'
The rest of the [tt]parsec.in[/tt] file must not change.
So is there a way to to that in awk.
Any help is greatly appreciated.
Thanks