【发布时间】:2014-04-18 15:14:03
【问题描述】:
为什么在执行以下脚本时,每个 printf(也尝试使用 echo)都打印在同一行上??
function read_dom () {
local IFS=\>
read -d \< ENTITY CONTENT
}
cat my_xml_file.xml | \
{ while read_dom; do
printf "(entity:content %s:%s)" $ENTITY $CONTENT
}
现在,这会产生单行输出:
(entity:content member:)(entity:content name:id)(entity:content /name:)
如何将其更改为多行,例如:
(entity:content member:)
(entity:content name:id)
(entity:content /name:)
【问题讨论】:
-
printf不是echo。你需要\n。 -
printf "(entity:content %s:%s)\n" $ENTITY $CONTENT
标签: bash while-loop printf echo newline