sed & awk
Objective
Hands-on practice with sed & awk in a Linux environment.
Tools & Technologies
sedawkcut
Key Commands
sed -i 's/old/new/g' file.txtawk '{print $1, $3}' fileawk -F: '{print $1}' /etc/passwdcut -d',' -f2 data.csvLab Steps
01
sed Substitution
Use sed s/find/replace/flags for in-place text substitution across files.
02
sed Line Operations
Delete, insert, and append lines using sed d, i, a commands.
03
awk Basics
Process structured text by field with awk, using -F for custom delimiters.
04
awk Patterns & Actions
Write awk programs with pattern/action pairs for conditional processing.
Challenges Encountered
- sed -i behaves differently on macOS vs GNU sed
- awk field separator must be set correctly for CSV with spaces
Key Takeaways
- sed is for stream editing; awk is for structured data processing
- awk is effectively a small programming language