Delete text between key words : sed
I have a file called 'get.txt' as below
******* cat get.txt There are five birds three dogs ten chickens and two cats ******* I need to delete all text from 'three' to 'chickens' including these 2 words like below: ******* There are five birds and two cats ******* can i do this using s/keyword1/keyword2/g Any ideas on how to get this working?? ta, jo |
Try:
Code:
sed "s/three.*chickens //g" get.txt |
Quote:
with the second globally. [edit]heh - beat by twenty seconds :}[/edit] What you want to do is s/keyword1.*keyword2//g Cheers, Tink |
gg
|
You guys are great ...thanks
i had to make a small change ...just a space between // s/keyword1.*keyword2/ /g thanks guys, Jo |
what if
what if I wanted to do the same thing, but remove 's/keyword1.*keyword2//g' but leave keyword1 & keyword2 in place.
using keyword1 and 2 as references btw, cause I could easily use the words before&after each :) |
Quote:
blahh............................ blahh.................. blahh......................... blahh................. I want to remove like s/[a-z].*$//g that will remove the h at the end, how can I leave that.... |
Quote:
ok scratch that I figured out how to remove the ...... at the end but still curious if I have a file that contains the dog jumps over the stick the cat crawls under stick now removing between the.*stick leaving "the stick" behind :) |
All times are GMT -5. The time now is 10:15 AM. |