back to labs
Sed: Global Substitution
EasySed & Awk3-5 minThe brief
A hosts file uses the placeholder 'localhost' many times — sometimes several on one line — and every occurrence needs to become 'server01'. That means every occurrence of the text 'localhost', including where it's part of a longer name (a name like 'db-localhost.example' would become 'db-server01.example').
Transform /root/work/hosts and save the result to /root/work/out.txt.
Mind the word 'every': some lines carry 'localhost' two or three times, and grading compares against the fully-substituted result, so stragglers get caught.
What you'll do
- Replace every occurrence of localhost with server01, including repeats on the same line
- Save the transformed text to /root/work/out.txt
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
