[英]How to use awk to print every word from a whole string?
I declared variable (string) containing k names of queues, I want to delete.我声明了包含 k 个队列名称的变量(字符串),我想删除。
How can i "loop" through the string and delete each queue?如何“循环”字符串并删除每个队列?
I'm having trouble with the awk command.我在使用 awk 命令时遇到问题。
thanks a lot!多谢!
你可以试试下面的命令吗?
awk '{for(i=1;i<=NF;i++) {printf "%s ", $i}; printf "\n"}' | xargs rm
there are many ways, I think the simplest will be方法很多,我觉得最简单的就是
$ vars="name1 name2 name3"
$ for v in $vars; do echo $v; done
name1
name2
name3
change echo to your script.将 echo 更改为您的脚本。
You can use xargs
:您可以使用xargs
:
queues="q1 q2 q3 q4"
echo ${queues} | xargs -n1 echo "Remove"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.