Append to start and end of first few lines

What sed command would allow me to append one string to the end of every line, a different string to the start of the first line, and a different string to the end of the fifth line?

So far I have

    sed 's/$/<br>/' $FILE1 >> $FILE1_GETS_APPENDED_TO_THIS_FILE

to append a html break statement to the end of each line in the file1. I need to add a header statement around the first 5 lines though. Therefore, the start of the first line needs to have <h3> appended to it and the end of the fifth line needs </h3> appened to it.



It's that easy:

sed 's/$/<br>/; 1 s/^/<h3>/; 5 s/$/<\/h3>/'

As you use $ to match the end of the line, use ^ to match the start of the line.

Then, for each of your commands (such as s), you can specify a line number (or range) where it should apply.

Add a number before a sed command to apply it only to that line. Add two numbers separated by a comma to specify a line number range. $ stands for the last line. For more information, see “addresses” in your sed manual.

sed -e '1 s/^/<h3>/' -e '5 s/$/<\/h3>/' -e '6,$ s/$/<br>/'

Need Your Help

What does CMFCButton::EnableFullTextTooltip do?

mfc mfc-feature-pack

I was trying the CMFCButton tooltips and found that if I call EnableFullText() the tooltips don't show.

Understanding boost::disjoint_sets

c++ boost disjoint-sets

I need to use boost::disjoint_sets, but the documentation is unclear to me. Can someone please explain what each template parameter means, and perhaps give a small example code for creating a