加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – shell脚本编写时命令未找到错误

发布时间:2020-12-13 22:54:50 所属栏目:Linux 来源:网络整理
导读:我正在尝试执行该程序,如下所示. ./chExt1.sh cpp test.CPP 这应该将test.CPP重命名为test.cpp,但我甚至认为这个脚本根本没有执行. 我一直得到这个“命令未找到错误”. 脚本如下: #!/bin/shnewExtension=$1;oldFile=$2; firstPart=`echo $oldFile | sed 's/
我正在尝试执行该程序,如下所示.

./chExt1.sh cpp test.CPP

这应该将test.CPP重命名为test.cpp,但我甚至认为这个脚本根本没有执行.
我一直得到这个“命令未找到错误”.
脚本如下:

#!/bin/sh
newExtension=$1;
oldFile=$2;

        firstPart=`echo $oldFile | sed  's/(.*)..*/1/'`
    newName="$firstPart.$newExtension";

#echo $oldFile
#echo $newName
mv "$oldFile" "$newName"
#echo "$oldFile"
#echo "$firstPart"
#echo "$newName"

解决方法

我终于解决了这个问题.当我将包含脚本的文本文件FTP然后在linux中的.sh中传输它时,出现了可怕的错误.我在emacs中从头开始编写并清除了所有内容.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读