Perl: How to print next line after matching a pattern?

后端 未结 7 2031
刺人心
刺人心 2021-01-06 15:52

I would like to print specific data after matching a pattern or line. I have a file like this:

#******************************    
List : car  
Design: S           


        
7条回答
  •  清歌不尽
    2021-01-06 16:09

    Solution using Perl flip-flop operator. Assumption from the input that you always have Total line at the end of the block of interest

    perl -ne '$a=/^#--/;$b=/^Total/;print if(($a .. $b) && !$a && !$b);' file
    

提交回复
热议问题