[英]BASH : Assigning sed result in an array on shell script
I used the sed function to exact the values from a XML file but I'm stuck on how to assign it to a array. 我使用sed函数从XML文件中精确取值,但是我在如何将其分配给数组上受困。
This is the sed code 这是sed代码
sed -n 's|<url>\(.*\)</url>|\1|p' filename.xml
The result is 结果是
VALUE1
VALUE2
VALUE3
VALUE4
How to assign these values to an array? 如何将这些值分配给数组?
Thank you 谢谢
将值放入(...)
内的分配中:
IFS=$'\n' array=($(sed -n 's|<url>\(.*\)</url>|\1|p' filename.xml))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.