我想将sed返回的内容保存在变量中,然后将其与其他文本进行比较,但是当我尝试保存它时,出现此错误。
这是代码:
#!/bin/bash
# Program name: test.sh
IPS=$HOME/Documentos/ips.txt
VERSION=/var/www/html/games/game/version
EOF=/dev/null
PASSWORD='password'
while read -r IP; do
echo $IP
sshpass -p $PASSWORD ssh -o 'StrictHostKeyChecking no' -o ConnectTimeout=1 -o ConnectionAttempts=1 $IP bash -c "'
REVISION=$(sed -n -e 6p $VERSION)
echo $REVISION
'" < $EOF
done < $IPS
这是输出:
192.168.232.69
sed: can't read /var/www/html/games/game/version: There is no file or directory
192.168.191.20
sed: can't read /var/www/html/games/game/version: There is no file or directory
192.168.191.19
sed: can't read /var/www/html/games/game/version: There is no file or directory
应该澄清的是,当我使用该命令而不保存它时,我没有任何错误,并且该文件存在于每个终端中。
答案 0 :(得分:0)
感谢大家的帮助,我使用此链接解决了该问题:
Assigning the value of a remote variable to a local variable in unix/linux