Get content between a pair of HTML tags using Bash

前端 未结 6 637
野趣味
野趣味 2020-11-30 09:53

I need to get the HTML contents between a pair of given tags using a bash script. As an example, having the HTML code below:



         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 10:53

    Using sed in shell/bash, so you needn't install something else.

    tag=body
    sed -n "/<$tag>/,/<\/$tag>/p" file
    

提交回复
热议问题