脚本abcd.sh:
####
ssh $user_name@$ftp_site pwd > /export/home/appwxsms/remotepathfile.lst;
pathofremote =`sed -n '1p' $HOME/remotepathfile.lst`
export pathofremote
#####
运行abcd.sh:
-bash:./abcd.sh
pathofremote: command not found
remotepathfile.lst > output.txt
-bash: /export/home/appwxsms/remotepathfile1.lst: Permission denied
运行 abcd.sh 脚本时,我无法将本地路径 remotepathfile.lst 中生成的文件的输出发送到变量pathofremote
另外,我无法将文件的输出保存到本地服务器中的另一个文件。
答案1
尽管变量分配中存在语法错误,该文件仍将按照您希望的方式填充。
foo =bar # This will attempt to run the command 'foo' with the parameter '=bar'
foo=bar # This will set the variable 'foo' equal to 'bar'
foo="$(bar)" # This will set the variable 'foo' to the output of the execution of 'bar'