Reputation: 11
I'm using this command here of grep and sed,
grep -w 'HN8 .* ATP' topol.top | sed -i 's_0[.]09_0.054_' topol.top
In my head, I thought the command is fetch lines that have HN8 and ATP, in those lines, replace 0.09 with 0.054. However, when this happens, Lines with HN7 or HN6 etc, with 0.09 are also getting swapped to 0.054.
Whys that? so I can understand how to just look for the values I require changing.
Upvotes: 1
Views: 56
Reputation: 781200
sed
can either process named files or stdin, but not both. And the -i
option can only be used when processing named files. So when you specify filename arguments, stdin is not used.
You should use the regexp as the address part of the sed
command.
sed -i '/HN8 .* ATP/s_0[.]09_0.054_' topol.top
Upvotes: 3