Running Script made in Visual Studio Code (on windows) on WSL Ubuntu returns "line 2: $'\r': command not found"

10,168

In the bottom-right corner of the window there is an indicator that says CRLF or LF [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.

enter image description here

CR is a bytecode for carriage return (from the days of typewriters) and LF similarly, for line feed. It just refers to the bytes that are placed as end-of-line markers.

Sources and references:

Share:
10,168

Related videos on Youtube

0siris
Author by

0siris

Updated on September 18, 2022

Comments

  • 0siris
    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
    0siris almost 6 years
    Thank you for the quick reply. I also appreciate you posting the sources, it was educational and makes sense.