As an example, take the following script.
#!/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`
Using Notepad++ editor.
1. In the Edit menu bar, select EOL Conversion sidebar and choose UNIX Format
2. In the Encoding menu bar, select Encode in UTF-8 without BOM
This way, you will not get the error /bin/bash: No such file or directory when running under Linux.
Similar Posts:
- How to Solve Error: set ff? /bin/bash^M: bad interpreter: No such file or directory
- [Solved] “/bin/bash^M: bad interpreter: No such file or directory”
- syntax error near unexpected token `do [How to Solve]
- [Solved] Python Error: /usr/bin/python^M: bad interpreter: No such file or directory
- UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1:
- Bash Shell: Check File Exists or Not [How to Do]
- Error reporting and resolution of Python 3 using binascii method
- Shell Error: bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory [How to Solve]
- error: attempt to read or write outside of disk ‘hd0’ [How to Solve]
- Linux shell script execution error: bad substitution [How to Solve]