如何将LFTP结果保存为变量,以便以后在脚本中使用。
这是我的基本命令:
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'
这显然是行不通的:
#!/bin/bash
output=""
lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21' > $output
echo "Test: " $output编辑:
问题似乎在于使用lftp -c不会产生任何输出。因此,变量是空的。所以问题是如何从lftp获得输出。
发布于 2016-06-07 10:43:34
使用Command Substitution将命令的输出存储在变量中:
output=`lftp -c 'open -e "mirror /path/to/remote /path/to/local/" ftp://username:password@ftp.domain.com:21'`
echo "Test: ${output}" https://stackoverflow.com/questions/37675585
复制相似问题