Error in Linux running file: bash: $’\r’: command not found

Problem description

After the SH file is written in windows, an error will be reported when running in Linux: bash: $’\ R’: command not found

Problem-solving

This is because the windows system uses - for file wrapping, while the UNIX system uses - for file wrapping

Problem-solving

Method 1

Install dos2unix for file conversion

yum install -y dos2unix

dos2unix aaa.sh

Method 2

Use VIM to open the file, and then use the command: set FF = UNIX </ KBD>, save the file

# use vim to open file
vim aaa.sh
# change formate
:set ff=unix
# save file
:wq

Read More: