bash - linux command line text file manipulation -


let's have text file following contents:

test blablabla test1 moreblabla atest blabla3 just*a*test blabla14 test88 lastblabla 

i want delete only line matches string "test" , line after without deleting lines contain string "test" in case want delete first , second lines not rest.

the above file example, contents of file varies string.

all examples found sed deal deleting lines contain string. want delete line is string.

just add ^ , $ around test regex anchor match.

sed -e '/^test$/,+1d' path/to/file 

or ^ *test *$ line containing 'test' possibly spaces.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -