以如下脚本为例,
#!/bin/bash
conn='mysql -upitt -p123456 -hhostname --default-character-set=UTF8 database'
`$conn -e "select Name from Product1 where Type='Live'" > a.txt`
`$conn -e "select Name from Product2 where Type='Live'" >> a.txt`
echo "query end"
echo "start check"
`cd /home/user/NameCheck`
`grep '@' a.txt | wc -l > result.txt`
使用Notepad++编辑器,
1.Edit菜单栏里选择EOL Conversion侧栏选择UNIX Format
2.Encoding菜单栏里选择Encode in UTF-8 without BOM
这样在Linux下跑不会报出/bin/bash: No such file or directory的错误