sed - Bash delete line beetwen two pattern containing "/" -


this question has answer here:

i've problem : able delete lines beetwen 2 pattern in file.

for example able delete line equals "line 1" beetwin "blablabla++" , "blablabla--"

line1 blablabla++ line1 line2 line3 blablabla-- line1 

i've found way sed :

sed '/blablabla++/,/blablabla--/{/line1/d}' ./file 

it working great. thing in real file more :

line1/script blablabla++ line1/script line2/script line3/script blablabla-- line1/script 

how ?

edit

i've choosen bad example.

the thing don't know line need delete (the line sent parameter). know 1 thing sure contain "/" characters.

the thing when :

sed '/blablabla++/,/blablabla--/{/$1/d}' ./file 

the "/" $1 contain mess sed.

you made bad example, because sed cmd works both input files. guess want match pattern containing / sed.

if want match literal /, can escape /s, however, makes codes not easy read, particularly have many /s wanted matched, can use \[c]pattern[c] here [c] char. example:

kent$  cat f //one// blablabla++ //one// //one two// //one three// blablabla-- //one//  kent$  sed '/blablabla++/,/blablabla--/{\@//one//@d}' f //one// blablabla++ //one two// //one three// blablabla-- //one// 

in above example, \@//one//@ pattern matching part.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -