Running Script made in Visual Studio Code (on windows) on WSL Ubuntu returns "line 2: $'\r': command not found"
In the bottom-right corner of the window there is an indicator that says
CRLF
orLF
[highlighted in green on the picture] which will let you set the line endings for a particular file. Clicking on the text will allow you to change the line endings as well.
CR
is a bytecode for carriage return (from the days of typewriters) andLF
similarly, for line feed. It just refers to the bytes that are placed as end-of-line markers.
Sources and references:
- Visual Studio Code: How to show line endings.
- VSC on GitHub: How to replace characters as newline break.
- Difference between CR LF, LF and CR line break types?
Related videos on Youtube
0siris
Updated on September 18, 2022Comments
-
0siris over 1 year
When I try to run a script made with Visual Studio Code on Windows in my Ubuntu WSL installation, I get the error:
line 2: $'\r': command not found
I ran into the question below:
How do I fix "$'\r': command not found" errors running Bash scripts in WSL?.
That all makes sense, however is there a way/setting on Visual Studio Code on windows to not have to use the dos2unix utility every time?
-
0siris almost 6 yearsThank you for the quick reply. I also appreciate you posting the sources, it was educational and makes sense.