- View specific lines
bash
sed -n '5,10p' file.txt
- View non-consecutive lines
bash
sed -n -e '5,7p' -e '10,13p' file.txt
- Replace every instance of of word
bash
# gi -> to ignore character case
sed 's/from/to/g' file.txt
# replace words in range
sed '30,40 s/from/to/g' file.txt
- Delete single line
bash
sed '10d' file.txt
- Delete from line to end of file
bash
sed '6,$d' file.txt