not FOUNKSH:2:在shell命令中执行时出错?
当我运行sh backuptest.sh时,会出现以下错误。代码或shell是否有问题not FOUNKSH:2:在shell命令中执行时出错?,shell,Shell,当我运行sh backuptest.sh时,会出现以下错误。代码或shell是否有问题 result : : not foundsh: 2: backuptest.sh: : not foundsh: 4: backuptest.sh: : not foundsh: 6: backuptest.sh: : not foundsh: 7: backuptest.sh: content of backuptest.sh #!/bin/sh -e location=`date +%Y%m%d`.
result :
: not foundsh: 2: backuptest.sh:
: not foundsh: 4: backuptest.sh:
: not foundsh: 6: backuptest.sh:
: not foundsh: 7: backuptest.sh:
content of backuptest.sh
#!/bin/sh -e
location=`date +%Y%m%d`.sql
mysqldump -u root -proot spider_db > $location
删除#/bin/sh-e
并重试
dos2unix backuptest.sh
然后再次执行
./backuptest.sh
ls/bin/sh行吗?看起来您的脚本包含DOS样式的行尾。试试
dos2unix
@glennjackman,你这个传奇人物!