Introduction
Welcome to the Survival Guide for the sed command. You have been dropped into a server with "realistic" system files and data.
- Configuration files are in
/home/laborant/sed_challenge/config/. - Log files are in
/home/laborant/sed_challenge/logs/. - Data files are in
/home/laborant/sed_challenge/data/.
Your mission is to perform 10 essential sed tasks ranging from basic substitution to advanced hold space techniques.
Before you jump into your favorite AI chatbot, try to solve these tasks using the manual pages man sed and experimenting, believe me its really worth it, even in AI era !
Man pages tips :
- Use
/to search inside the man pages. - Search for keywords like "substitution", "address", "in-place", "regex", etc.
- Press
nto go to the next occurrence of your search term, orNto go to the previous occurrence. - Press
qto quit the
There is a cheatsheet available in solution page, but writing your own is worth it!
Task 1: Simple Substitution
File: /home/laborant/sed_challenge/config/network.conf.
Goal: Replace the first occurrence of dhcp with static in the file.
Save to /home/laborant/q1_network.txt.
Task 2: Global Substitution
File: /home/laborant/sed_challenge/data/services.txt.
Goal: Replace ALL occurrences of tcp with TCP (uppercase).
Save to /home/laborant/q2_services.txt.
Task 3: Regex & Metacharacters
File: /home/laborant/sed_challenge/config/hosts.conf.
Goal: Modify IP addresses that start with 10.0.1 to start with 10.0.10.
Example: 10.0.1.10 → 10.0.10.10
Save to /home/laborant/q3_hosts.txt.
Task 4: Line Ranges
File: /home/laborant/sed_challenge/logs/system.log.
Goal: Extract ONLY lines 5 to 10 from the log file.
Save to /home/laborant/q4_filtered.txt.
Task 5: Line Deletion
File: /home/laborant/sed_challenge/logs/application.log.
Goal: Delete ALL lines containing the word DEBUG.
Save to /home/laborant/q5_clean.log.
Task 6: Line Insertion
File: /home/laborant/sed_challenge/config/hosts.conf.
Goal: Insert the line # Welcom to Iximiuz BEFORE the line containing # Production Servers.
Save to /home/laborant/q6_modified.txt.
Task 7: Multi-commands
File: /home/laborant/sed_challenge/logs/system.log.
Goal: Perform these 3 operations in a single command:
- Replace
ERRORwithCRITICAL - Replace
WARNINGwithWARN - Delete all lines containing
INFO
Save to /home/laborant/q7_transformed.txt.
Phase 3: Advanced Techniques
Task 8: In-Place Editing
File: /home/laborant/sed_challenge/config/network.conf.
Goal: Modify the file DIRECTLY by replacing ONBOOT=no with ONBOOT=yes.
⚠️ WARNING: Create a backup with the .backup extension before modification!
Task 9: Alternate Delimiter
File: /home/laborant/sed_challenge/data/users.txt.
Goal: Replace every /bin/bash with /bin/zsh using a different delimiter (for example .) to avoid escaping /.
Save to /home/laborant/q9_shells.txt.
Task 10: Filter by Pattern
File: /home/laborant/sed_challenge/data/services.txt.
Goal: Extract only comment lines (those starting with #) and discard everything else.
Save to /home/laborant/q10_comments.txt.
Good luck! 🚀
Level up your Server Side game — Join 20,000 engineers who receive insightful learning materials straight to their inbox