我尝试编写自己的Shell脚本,但遇到了一些麻烦。 我该怎么办?
./test_online.sh: line 47: host.booking.yh: command not found
host_tmp='host.booking'
host=$host_tmp'kpt' $host_tmp'yh' $host_tmp'mt'
for each_site in $host
do
#cd /home/toptrain/workspace/op_tools/ansible && ansible-playbook -i hosts/$each_site test.yaml --extra-vars "branch=$branch" -v --tags "update" -v
echo $each_site
在for循环之后,它可以输出host.booking.kpt host.booking.yh host.booking.mt。但出现此错误
答案 0 :(得分:0)
host=$host_tmp'kpt' $host_tmp'yh' $host_tmp'mt'
如果要为变量分配包含空格的内容,则必须引用这些空格,例如。 g。:
host="$host_tmp.kpt $host_tmp.yh $host_tmp.mt"