Extract Value between XML tags with SED

后端 未结 3 1812
礼貌的吻别
礼貌的吻别 2021-01-22 04:36

I am receiving data from a server in the following format:

gin1601DepthOfBook<         


        
3条回答
  •  时光说笑
    2021-01-22 05:20

    Something like this would work:

     sed -e 's/<\/sessionId>/<\/sessionId>\n/g' | sed -n 's/.*\([^<]*\)<\/sessionId>.*/\1/p'
    

    First part is because sed tries to eat up as much of a single line as possible when matching, this will find all sessionId occurences and split them up on a line on its own.

    Next part matches stuff between the sessionId tags.

提交回复
热议问题