Может быть, это поможет -
sed '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
Исполнение:
[jaypal:~/Temp] cat file1
DIVIDER
Sometext_string
many
lines
of random
text
DIVIDER
Another_Sometext_string
many
many
lines
DIVIDER
Third_sometext_string
[jaypal:~/Temp] sed '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
DIVIDER
[begin]Sometext_string[end]
many
lines
of random
text
DIVIDER
[begin]Another_Sometext_string[end]
many
many
lines
DIVIDER
[begin]Third_sometext_string[end]
UPDATE:
Эта версия будет обрабатывать одну пустую строку после первого DIVIDER.
[jaypal:~/Temp] sed -e '0,/DIVIDER/{n;s/.*/[begin]&[end]/;}' -e '/DIVIDER/{n;s/.*/[begin]&[end]\n/;}' file1
DIVIDER
[begin]Sometext_string[end]
many
lines
of random
text
DIVIDER
[begin]Another_Sometext_string[end]
many
many
lines
DIVIDER
[begin]Third_sometext_string[end]
[jaypal:~/Temp]
ОБНОВЛЕНИЕ 2:
Сейчас нет других вопросов, так что я решил предложить альтернативное awk
решение, если хотите? :)
awk '/DIVIDER/{print;getline;sub(/.*/,"[begin]&[end]");print;next}1' file1
[jaypal:~/Temp] awk '/DIVIDER/{print;getline;sub(/.*/,"[begin]&[end]\n");print;next}1' file1
DIVIDER
[begin]Sometext_string[end]
many
lines
of random
text
DIVIDER
[begin]Another_Sometext_string[end]
many
many
lines
DIVIDER
[begin]Third_sometext_string[end]
[jaypal:~/Temp]
Это для обработки первой пустой строки после DIVIDER -
[jaypal:~/Temp] awk '/DIVIDER/{count++;print;getline;if(count==1) sub(/.*/,"[begin]&[end]");else sub(/.*/,"[begin]&[end]\n");print;next}1' file1
DIVIDER
[begin]Sometext_string[end]
many
lines
of random
text
DIVIDER
[begin]Another_Sometext_string[end]
many
many
lines
DIVIDER
[begin]Third_sometext_string[end]
[jaypal:~/Temp]