See Sed1Liners
1
Source: tecmint
sed '' # print whole file
sed -n '' # print nothing (-n disables auto print)
sed -n '5,10p' # lines 5 through 10
sed '20,35d' # all but lines 20..35
sed -n -e '5,7p' -e '10,13p' # print non-contiguous ranges
sed 's/version/story/g' # regex search replace all occurrences
sed 's/version/story/' # regex search replace first occurrence
sed 's/version/story/gi' # case insensitive
sed '30,40 s/version/story/g' # only search/replace in lines 30..40
sed '/^#\|^$\| *#/d' # remove matching lines
sed -n '/^Jul 1/ p' # print matching lines (like grep)
sed G # insert a blank line for every line
sed '/./ G' # insert a blank line for every nonempty line
sed -i 's/\r//' # dos2unix
sed -i'.orig' 's/this/that/gi' myfile.txt # modify myfile.txt, save backup to myfile.txt.orig
sed 's/^\(.*\),\(.*\)$/\2\, \1/g' names.txt # interchange matched words
sed '/services/ s/start/stop/g' msg.txt # search/replace only on matching lines
sed -i 's/that/this/gi;s/line/verse/gi' myfile.txt # two subs in one command