The sites' backend is moving from 10.0.0.5 to 10.0.0.9. The ~/sed-lab/conf directory holds thirty configs, and each has the address twice: on the backend= line and on the # rollback: line. The rollback line is not to be changed — it brings the old address back if the move fails. Opening thirty files in an editor takes a while, and a colleague suggests a single sed command. Run it on the first file.
Run your colleague's replacement
In ~/sed-lab/conf, run your colleague's replacement on site-01.conf, then look at the file itself.
First, predict
What will sed print?
Now start the exercise, run the command and compare your prediction with the output.
If your colleague's replacement were written to all thirty files, which address would the rollback lines point to?
-
sed deleted no lines: the rollback line is still in its output, with the new address.
-
In sed's output the rollback line already has 10.0.0.9: the replacement went through it too.
-
The s command puts the new text in place of the match: the rollback line in the output has one address, 10.0.0.9.
The rollback line would point to the new server, leaving nowhere to roll back to.