In this article we will provide you bash code to resolve $’\r’: command not found error. This happens because of wrong new line encoding.
Since bash is a linux based OS terminal scripting engine so it follows linux principles. One of that is line feed. Linux uses
LF encoding while windows uses
When we create a file in windows, by default it takes CRLF encoding. It works everywhere but when it comes to shell scripts, it doesn’t. Bash needs
So, this error occurs when you create your bash script in windows and run on linux terminal.
Code Example –
# Open code in notepad++ or VSCode # ctrl+a to select all the code # look for text encoding like as shown in the below image # Select LF encoding # Run bash script in terminal successfully