在写shell脚本的时候有时候需要在notepad++上进行更改好后再进行测试,然而这个操作就容易出现问题....
[root@opop-04:/data/code/script/service-manage]# bash weixinapp-1.sh restart
weixinapp-1.sh: line 1: ?#!/bin/bash: No such file or directory
....
....
解决办法
[root@opop-04:/data/code/script/service-manage]# cat -A izy-cczyz-weixinapp-1.sh
M-oM-;M-?#!/bin/bash$ ====>明显第一行有问题,是utf-8格式编码的问题
source /etc/init.d/functions$
#M-eM-8M-8M-iM-^GM-^OM-iM-^EM-^MM-gM-=M-.$
PORT=`for i in {2..7};do lsof -i:820$i | grep LISTEN | wc -l;done`$
PORT_PID=`for i in {2..7};do lsof -i:820$i | grep LISTEN | awk ‘{print $2}‘;done`$
$
用notepad++ 转行成unix下文件 并且将文件编码格式换成utf-8 无BOM编码即可
相关文章
- 10-29git提交报错:The file will have its original line endings in your working directory
- 10-29Found 1 slaves: Use of uninitialized value in printf at /usr/local/percona-toolkit/bin/pt-online-schema-change line 8489
- 10-29", line 1, in
NameError: name 'f' is not defined">Python2 错误记录1File " ", line 1, in NameError: name 'f' is not defined - 10-29<command-line>:0:12: fatal error: curses.h: No such file or directory 报错解决方法
- 10-29xmanager运行报错:bash: /usr/bin/xterm: No such file or directory
- 10-29/usr/local/bin/celery: No such file or directory
- 10-29Git错误:Corrupted time file (line 1, 1)完美解决
- 10-29【异常】~/.bash_profile:source:44: no such file or directory: /usr/local/Cellar/nvm/0.34.0/nvm.sh
- 10-29Found option without preceding group in config file /etc/my.cnf at line 1!
- 10-29[已解决]chroot: failed to run command ‘/bin/bash’: No such file or directory