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