-1

I have a file named "check", which contains the following,

calendar: A
Des: bad
04/12/2009 00:00
09/11/2010 00:00
calendar: B
Des: bad
04/09/2013 00:00
08/08/2013 00:00
calendar: B1
Des: bad
04/03/2014 00:00
04/02/2014 00:00
calendar: C
Des: bad
04/05/2009 00:00
09/11/2010 00:00

I have to filter only the calendar: B* and the corresponding des and dates and place it in a separate file using bash scripting the above given is an example and the actual file will contain more than 200 lines. I tried

 awk '/calendar: B/{print}' check

as the command gives the tag and not the details below to it. I need to have an command which gives the details too

Inian
  • 80,270
  • 14
  • 142
  • 161
Vicky
  • 31
  • 7

1 Answers1

0

You can use this awk command.

awk '/^calendar/{p=0} /^calendar: B/{p=1} p' check
oguz ismail
  • 1
  • 16
  • 47
  • 69