我正在如下所示的shell脚本中使用API:
response="$(curl $URL_EXE)"
<projects><project><modelVersion>4.0.0</modelVersion><groupId>com.networks.app</groupId><artifactId>operation-platform</artifactId><version>1.0</version><packaging>tar.xz</packaging><description>POM was created by Sonatype Nexus</description></project>
<project><modelVersion>4.0.0</modelVersion><groupId>com.networks.app</groupId><artifactId>operation-platform</artifactId><version>1.0.0</version><packaging>tarasdfd.xz</packaging><description>POM was created by Sonatype Nexus</description></project></projects>
我需要检索标签“ packaging”的值。它具有多个值。我尝试使用以下命令
execID=$( echo $response | awk -v FS="(packaging>|</packaging)" '{print $2'})
echo "test" ${execID}
但是上面只会打印第一个值。我的意思是#“ tar.xz”#
我需要给定标签的所有出现的值。如下所示:
tarasdfd.xz
我们非常感谢您的帮助。谢谢