- Replace string in a file
sed 's/<string>/<replaced_string>/' <filename>
- Replace the nth occurence of a pattern
sed 's/<string>/<replaced_string>/n' <filename>
- Replace all occurences of the pattern
sed 's/<string>/<replaced_string>/g' <filename>
- Replace from nth occurence to all occurences:
sed 's/<string>/<replaced_string>/4g' <filename>
- Delete a particular line from a file (assuming line 3)
sed '3d' <filename>
- Delete the last line of the file
sed '$d' <filename>
- Delete a number of lines (assuming from line 5 to 10)
sed '5,10d' <filename>