如何在不同路径的多个文件上使用 xmlstarlet?
How to xmlstarlet on multiple files in different paths?
我正在使用 C Shell。
我的工作目录:
cd /mnt/FusionOATS/CRM/Research/rys/
My Current Working xmlstarlet 命令(对直接位于工作目录下的 2 个文件执行 xmlstarlet 操作并将结果粘贴到输出文本文件中):
foreach xmlfile ( ResultReport1.xml ResultReport2.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo3.txt
end
现在我需要对位于不同路径的文件执行此操作,如下所示:
工作Directory/ResultReport1.xml
工作Directory/ResultReport.xml
工作Directory/Test3/ResultReport3.xml
我试过这个:
foreach xmlfile ( ResultReport1.xml ResultReport2.xml /Test3/ResultReport3.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo4.txt
end
但是,出现以下错误:
无法加载外部实体“/Test3/ResultReport2。xml”
我可以和 xmlstarlet 一起做吗?请建议。谢谢
只需删除文件路径开头的斜杠即可解决错误:
这有效:
foreach xmlfile ( ResultReport1.xml ResultReport2.xml Test3/ResultReport2.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo4.txt
end
我正在使用 C Shell。
我的工作目录:
cd /mnt/FusionOATS/CRM/Research/rys/
My Current Working xmlstarlet 命令(对直接位于工作目录下的 2 个文件执行 xmlstarlet 操作并将结果粘贴到输出文本文件中):
foreach xmlfile ( ResultReport1.xml ResultReport2.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo3.txt
end
现在我需要对位于不同路径的文件执行此操作,如下所示:
工作Directory/ResultReport1.xml
工作Directory/ResultReport.xml
工作Directory/Test3/ResultReport3.xml
我试过这个:
foreach xmlfile ( ResultReport1.xml ResultReport2.xml /Test3/ResultReport3.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo4.txt
end
但是,出现以下错误:
无法加载外部实体“/Test3/ResultReport2。xml”
我可以和 xmlstarlet 一起做吗?请建议。谢谢
只需删除文件路径开头的斜杠即可解决错误:
这有效:
foreach xmlfile ( ResultReport1.xml ResultReport2.xml Test3/ResultReport2.xml )
xmlstarlet sel -t -m '//RESULT_STEP' -v '@time_stamp' -o '|' -v '@step_name' --nl "$xmlfile" >> /scratch/rys/view_storage/outroo4.txt
end