shell脚本运作./tt.sh: line 1: 锘縲hile: command not found
shell脚本运行./tt.sh: line 1: 锘縲hile: command not found
while true
do
while read line
do
echo $line>>/home/aa/user/wu/test/b.log
sleep 1
done</home/aa/user/wu/test/a.log
done
运行报错:[iomssapp@master test]$ ./tt.sh
./tt.sh: line 1: 锘縲hile: command not found
./tt.sh: line 2: syntax error near unexpected token `do'
./tt.sh: line 2: `do'
是怎么回事?用的是secureCRT。之前运行成功过。请高手指教!
------解决方案--------------------
“while”变成了“锘縲hile”,怀疑是BOM(https://en.wikipedia.org/wiki/Byte_order_mark)引起的问题,你是用什么编辑器写的脚本?
试试下面两个办法:
1. dos2unix:如果你现在的*nix的下有dos2unix的话,
dos2unix tt.sh
或者 2. 重新保存文件,注意选“utf-8 without BOM”之类的文件格式。
------解决方案--------------------
shell脚本千万不能在win下用记事本打开,会出事的。
另外编辑shell脚本还是vim之类的编辑器比较好用。
------解决方案--------------------
文件格式问题
1. dos2unix
2. vi 打开文件,:set fileformat=unix保存
while true
do
while read line
do
echo $line>>/home/aa/user/wu/test/b.log
sleep 1
done</home/aa/user/wu/test/a.log
done
运行报错:[iomssapp@master test]$ ./tt.sh
./tt.sh: line 1: 锘縲hile: command not found
./tt.sh: line 2: syntax error near unexpected token `do'
./tt.sh: line 2: `do'
是怎么回事?用的是secureCRT。之前运行成功过。请高手指教!
------解决方案--------------------
“while”变成了“锘縲hile”,怀疑是BOM(https://en.wikipedia.org/wiki/Byte_order_mark)引起的问题,你是用什么编辑器写的脚本?
试试下面两个办法:
1. dos2unix:如果你现在的*nix的下有dos2unix的话,
dos2unix tt.sh
或者 2. 重新保存文件,注意选“utf-8 without BOM”之类的文件格式。
------解决方案--------------------
shell脚本千万不能在win下用记事本打开,会出事的。
另外编辑shell脚本还是vim之类的编辑器比较好用。
------解决方案--------------------
文件格式问题
1. dos2unix
2. vi 打开文件,:set fileformat=unix保存