Linux SED Command Game
Linux SED Command Cheat Sheet
- Replace text:
sed 's/old/new/g' filename
- Delete lines containing:
sed '/pattern/d' filename
- Print specific lines:
sed -n '5p' filename
- Replace only first occurrence:
sed 's/old/new/' filename
- Replace second occurrence:
sed 's/old/new/2' filename
- Append text at end of line:
sed 's/$/ END/' filename
- Insert text at beginning of line:
sed 's/^/START /' filename
- Delete all blank lines:
sed '/^$/d' filename
- Replace only on lines containing:
sed '/match/s/old/new/g' filename