The basic idea is to read lines one at a time from the input files, apply commands from the list, in order, to each line and write the edited output to the standard output.
sed 'list of ed commands' filenames
Below we will provide a series of useful usages.
sed 's/Amit/JHack/g' *.c *.h > output
However the above does not change the files. We need to use some shell programming to complete the job. See the example in Section 4.7.11.
sed 's/^/\t/' file1
where -> represents the tab character. We can then just pipe the output to lpr to send it to the printer.
sed 's/^/->/' file1 | lpr
cat file2 | sed 3q
sed -n '/pattern/p'
does the same job as grep.
sed -n '20,30p' print lines 20 through 30 sed '1,10d' delete lines 1 through 10 sed '1,/^$/d' delete up to and including the first blank line sed '$d' delete last line