I have a file look like:
login1.stampede(73)$ cat mc_input
800 ! n_pass
300 ! n_equil_pass
6 6 6 ! simulation cell dimension in x, y, and z
700 ! Tinit
100 ! Tmin
700 ! Tmax
-10 ! Tinc
Li -6 Fe 0 ! mu init
Li -6 Fe 0 ! mu min
Li 6 Fe 0 ! mu max
Li 0.3 Fe 0 ! mu inc
4 ! number of increments between structure output (0 indicates no output)
1 ! calculate average correlations yes(1) or no (0)
0 ! temp_chem = 0 if temperature runs 1 if chem runs
now I would like to target the line
Li -6 Fe 0 ! mu init
and replace -6 with another mu_init=-3, how could I achieve it with sed? thank you. Therefore the result should be :
Li -3 Fe 0 ! mu init
and "Fe 0" can be all kinds of other element-number combination and we will keep it fixed, for example "H 2", "Ge 3.2"
what i currently have is:
sed -i 's,^\(Li \).*! mu init,\1$mu_init' Fe 0 ! mu init',' mc_input
but it does not work....
sedcommand, it looks like you are looking for a line starting with(Li), which I do not see in your source file. You need to a little more specific.