Command Example Description
p sed -n '1,4 p' input.txt Print lines 1-4
p sed -n -e '1,4 p' -e '6,7 p' input.txt Print lines 1-4 and 6-7
d sed '1,4 d' input.txt Print lines except 1-4
w sed -n '1,4 w output.txt' input.txt Write pattern space to file
a sed '2 a new-line' input.txt Append line after
i sed '2 i new-line' input.txt Insert line before
Comments