Split files based on file content and pattern matching

前端 未结 6 2085
执笔经年
执笔经年 2020-12-15 22:45

I need your help with formate a txt file using bash/linux. The file looks like the following, it always has a line called Rate: Sth then it follows with the details in the v

6条回答
  •  悲&欢浪女
    2020-12-15 22:52

    This might work for you:

    csplit -z -f 'temp' -b '%02d.txt' file /Rate/ {*}
    

    This will produce files temp00.txt, temp01.txt...

    If you only want the Rate line then;

    sed -i '/Rate/!d' temp*.txt
    

提交回复
热议问题