XML文件:提取物领域文件
<head>
<head2>
<dict type="abc" file="/path/to/file1"></dict>
<dict type="xyz" file="/path/to/file2"></dict>
</head2>
</head>
我需要提取此文件列表。所以输出将是
/path/to/file1
/path/to/file2
到目前为止,我设法以下。
grep "<dict*file=" /path/to/xml.file | awk '{print $3}' | awk -F= '{print $NF}'
你可以用'xmllint'或'xmlstarlet'? 'awk/sed/grep'不是处理xml的正确工具 – Inian
'xmllint'很好 – CR7