linux下执行sh脚本,提示Command not found解决办法

1、确保用户对文件有读写及执行权限

chmod a+x test.sh

2、然后修改文件格式(如果是从winodws搬过来的会显示dos格式,要把它改成unix格式)

(1)使用vi工具

  vi test.sh

(2)利用如下命令查看文件格式 
          :set ff 或 :set fileformat 
         可以看到如下信息 
           fileformat=dos 或 fileformat=unix 
 (3) 利用如下命令修改文件格式 
           :set ff=unix 或 :set fileformat=unix 
           :wq (存盘退出)

3、最后再执行

./test.sh

你可能感兴趣的:(linux下执行sh脚本,提示Command not found解决办法)