Ubuntu shell Script syntax error near unexpected token `$‘{\r‘‘

Problem description

Write a shell script using vs code, but keep reporting errors:

syntax error near unexpected token `$’{\r’’

Solution:

Reference: syntax error near unexpected token in R

Convert the CRLF in the lower right corner of vs code to LF:

Read More: