Using sed , awk to extract lines of data between a pattern till the beginning of a line with a special character -
i have following xml
## 13 aug 2013 14:53:44, 390 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:53:44, 390 [info] orderid 105 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:55:45, 490 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:53:44, 390 [info] orderid 105 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml>
i want search particular line orderid "example orderid 100" , print both line , below till next order line starting doulbe hash(##) if search orderid 100 should following
## 13 aug 2013 14:53:44, 390 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:55:45, 490 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml>
your records nicely separated set record separator ##
, search orderid
want:
$ awk '/orderid 100/{print rs $0}' rs='##' ors='' file ## 13 aug 2013 14:53:44, 390 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml> ## 13 aug 2013 14:55:45, 490 [info] orderid 100 otherinfo <somexml>details <info>details<info> <info1>details<info1> </somexml>
Comments
Post a Comment