0

I have a file with its contents

apple
ball
....
....
....
cat 
dog

from this, I want to get everything between lines with ball and cat, including ball but not cat. How can I accomplish it? I used the command sed -n '/ball/,/cat/ p' filename, but it would print out ball as well which I do not want.

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
menten
  • 45
  • 9

1 Answers1

0

Could you please try following.

awk '/cat/{found=""} /ball/{found=1} found' Input_file

With sed:

sed -n '/ball/,/cat/{/cat/!p;}' Input_file
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93