Shell scripting - split xml into multiple files

后端 未结 3 1617
清歌不尽
清歌不尽 2020-12-21 21:53

Am trying to split a big xml file into multiple files, and have used the following code in AWK script.

// {
        rfile=\"fileItem\" count          


        
3条回答
  •  青春惊慌失措
    2020-12-21 22:20

    If your XML is really that well formed and consistent then all you need is:

    awk -F'[<>]' '
    // { header="" ORS $0; next }
    / { close(out); out="item_" $3; $0=header ORS $0 }
    { print > out }
    ' file
    

    The above is untested of course since you didn't provide sample input/output for us to test a possible solution against.

提交回复
热议问题