How to split file on first empty line in a portable way in shell (e.g. using sed)?

前端 未结 4 430
温柔的废话
温柔的废话 2021-01-11 14:49

I want to split a file containg HTTP response into two files: one containing only HTTP headers, and one containg the body of a message. For this I need to split a file into

4条回答
  •  花落未央
    2021-01-11 15:08

    Given the awk script

    BEGIN { fout="headers" }
    /^$/ { fout="body" }
    { print $0 > fout }
    

    awk -f foo.awk < httpfile will write out the two files headers and body for you.

提交回复
热议问题