所以我有个烦人的问题。我有一个脚本可以更改给定文本文件上的一些配置。要更改该特定文件,我必须首先销毁KVM上的虚拟机来宾。问题是,每次它停止时,脚本的输出中都有一个空格,如您所见:
vfp-8vr Found!
Check if vfp-8vr has stopped ................................. [OK]
Check if vfp-8vr node has changed ............................ [OK]
Check if vfp-8vr has started ................................. [OK]
vfp-9vr Found!
Check if vfp-9vr has stopped ................................. [OK]
Check if vfp-9vr node has changed ............................ [OK]
Check if vfp-9vr has started ................................. [OK]
vfp-10vr Found!
Check if vfp-10vr has stopped ................................. [OK]
Check if vfp-10vr node has changed ............................ [OK]
Check if vfp-10vr has started ................................. [OK]我在我的脚本中包含了/dev/null,因为它隐藏了输出,理论上它可以工作,但是仍然有一个银行空间显示,不管.
for i in "${arr[@]}"
do
if [[ -n "$i" ]]
then
echo "$i Found!"
virsh destroy $i &> /dev/null
echo -e "Check if \e[32m$i\e[0m has stopped ................................. [OK]"
virsh numatune $i $opt_node0
echo -e "Check if \e[32m$i\e[0m node has changed ............................ [OK]"
virsh start $i &> /dev/null
echo -e "Check if \e[32m$i\e[0m has started ................................. [OK]"
fi
done有没有人知道我如何在后台运行virsh destroy,而不显示输出中那个烦人的空间呢?
免责声明:我也使用过[Command] > /dev/null 2>&1 &,也使用了相同的东西:/
发布于 2021-12-09 00:23:45
愚蠢的我,我忘记将/dev/null添加到命令中:
Check if vfp-8vr has stopped ................................. [OK]
Check if vfp-8vr node has changed ............................ [OK]
Check if vfp-8vr has started ................................. [OK]
vfp-9vr Found!
Check if vfp-9vr has stopped ................................. [OK]
Check if vfp-9vr node has changed ............................ [OK]
Check if vfp-9vr has started ................................. [OK]
vfp-10vr Found!
Check if vfp-10vr has stopped ................................. [OK]
Check if vfp-10vr node has changed ............................ [OK]
Check if vfp-10vr has started ................................. [OK]谢谢社区!
https://stackoverflow.com/questions/70283181
复制相似问题