>
>>Может это подойдет, у меня не работает
>>$ echo -e "l1\tsed;sed;\nl2 notsed;\nsed" | sed -e 's/[[:<:]]sed[[:>:]]/\n&\n/g'
>
>не работает :( Короче читаем это. Насколько я понимаю сколь либо простой замены якорям \< и \> найти не удастся.
Matching words with \< and \>
Searching for a word isn't quite as simple as it at first appears. The string "the" will match the word "other." You can put spaces before and after the letters and use this regular expression: " the ." However, this does not match words at the beginning or end of the line. And it does not match the case where there is a punctuation mark after the word.
There is an easy solution. The characters "\<" and "\>" are similar to the "^" and "$" anchors, as they don't occupy a position of a character. They do "anchor" the expression between to only match if it is on a word boundary. The pattern to search for the word "the" would be "\<[tT]he\>." The character before the "t" must be either a new line character, or anything except a letter, number, or underscore. The character after the "e" must also be a character other than a number, letter, or underscore or it could be the end of line character.
Одно из наипростейших решений:
You can compensate by using the alternation mechanism. Matching the word "the" in the beginning, middle, end of a sentence, or end of a line can be done with the extended regular expression:
(^| )the([^a-z]|$)
There are two choices before the word, a space or the beginining of a line. After the word, there must be something besides a lower case letter or else the end of the line.