[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: search and replace



On Wed, May 02, 2007 at 08:21:07PM +0300, Nikolay Nikolaev wrote:
> Народ подскажите а можно ли sed'ом удалить 
> блок текста? а не только в одной строке 
> вроде как g должна спасти

http://www.grymoire.com/Unix/Sed.html#uh-47

The next example would delete everything between "ONE" and "TWO:"

#!/bin/sh
sed '
/ONE/ {
# append a line
N
# search for TWO on the second line
/\n.*TWO/ {
# found it - now edit making one line
s/ONE.*\n.*TWO/ONE TWO/
}
}' file




Reply to: