似乎什么是与此代码653-401不能重命名在shell脚本中使用的MV
#/usr/bin/ksh
RamPath=/home/RAM0
RemoteFile=Site Information_2013-07-11-00-01-56.CSV
cd $RamPath
newfile=$(echo "$RomoteFile" | tr ' ' '_')
mv "$RemoteFile" "$newfile"
错误我运行该脚本后得到了这个问题:
MV网站Information_2013-07-11- 00-01-56.CSV 至:653-401无法重命名站点信息_2013-07-11-00-01-56.CSV 路径名中的文件或目录不存在。
该文件存在于该目录中。我也在变量中加了双引号。上面同样的错误。
oldfile=$(echo "$RemoteFile" | sed 's/^/"/;s/$/"/' | sed 's/^M//')
newfile=$(echo "$RomoteFile" | tr ' ' '_')
mv "$RemoteFile" "$newfile"
'“$ RomoteFile”'?? – shellter
在'#/ usr/bin/ksh'下面的一行中添加'set -u'并重新运行你的例子。 shell会用'-ksh:RomoteFile:parameter not set'作出响应 –
问题的关键是由于拼写错误的变量,字符串“$ newfile”是空的。用'ksh -x script'运行脚本来查看每行是如何执行的。 –