Syntax error near unexpected token `newline’script cannot be executed

Problem description
The script is executed to report an error with the following message:

: No such file or directory
: command not found
./ line 4: syntax error near unexpected token `newline'
'/ line 4: `case "$1" in  

Problem analysis
Look for the script. The script is fine, so I wonder if the file format is incorrect.
view the file with the following command,

cat -A

Find that in, the newline ends with ^M$

server="$( dirname "${BASH_SOURCE[0]}" )" && pwd ^M$
cd $server^M$
case "$1" in  ^M$

The solution
Execute the following statement to convert to a line break of $in the Linux environment


View the conversion file through Cat-a as:

server="$( dirname "${BASH_SOURCE[0]}" )" && pwd $
cd $server$
case "$1" in  $

Read More: