Sed print between patterns the first match result

前端 未结 2 897
忘掉有多难
忘掉有多难 2021-01-29 06:04

the file like:

File /home/user/

int yl_init(void);

File /home/user/

int yl2_init(void);

I want u

2条回答
  •  自闭症患者
    2021-01-29 07:05

    This might work for you (GNU sed);

    sed '/File/,/;/!d;/;/q' file
    
    • /File/,/;/!d delete all lines not between File and ;
    • /;/q quit on encountering a line containing ;

提交回复
热议问题