When Linux executes the sh file, it encounters that the cd 'directory' cannot be found

Write multiple php commands to the same sh file for execution in linux

#!/bin/bash/
cd /www/sf/
/usr/local/bin/php xxx.php 
/usr/local/bin/php xxx1.php 
/usr/local/bin/php xxx2.php 
``
然后执行命令

sh xxx.sh

有的时候会出现 找不到`/www/sf/`目录
为什么呢,找了下资料,是因为linux和windows下的回车换行符号不一致导致的出错。
也就是说文件的格式有问题
解决方案

vim xxx.sh
// View format
: set ff
// Set format
: set ff=unix
`` fileformats[ffs] (Vim 才有) 可指定多个,会依加载的档案形式来调整 ff。 例如 :set ffs=unix, dos ff=unix`
is default to unix format, but if the read is dos The file in the format will be automatically adjusted to the dos format, so that it will be saved in the dos format when saving (the status bar will be displayed). . If you want to change to unix format at this time, you can: set ff=unix and then save the disk will be converted to unix format, and vice versa.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775442&siteId=291194637