Interview Prep/Linux/Packages, Shell & Text Tools

Show practical sed usage.

IntermediateConceptPackages, Shell & Text Tools
Answer
sed -n '100,120p' big.log                       # print a line range
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i.bak 's/old/new/g' app.conf               # in-place with backup
sed '/^\s*#/d; /^\s*$/d' nginx.conf             # drop comments and blanks
sed -i '/^server 10.0.0.5/d' upstream.conf      # delete matching lines

GNU sed -i takes an optional suffix; BSD/macOS sed needs -i ''.

All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools