If you encountered this error when executing a bash script its probably because you use a script that was written under Windows and you want to use this in an Unix system now. The problem is that the control characters of your file are different, depending on wich OS (Operating System) you use.
1. Fix via Stream Editor
A quick fix for this is to simply replace the control characters:
sed $'s/\r$//' setup.sh > setup.Unix.sh
2. Use dos2unix package
If you want to use a package rather than the stream editor, dos2unix should be your pick. Simply install it via apt:
sudo apt-get install dos2unix
Then just pick your file:
If you want to convert multiple files at once you may use the suggested method on Stackoverflow:
find . -type f -print0 | xargs -0 dos2unix
If nothing of this fixed your issue, please leave a comment and I will try to look into it, as well as add it here.
I am a developer and entrepreneur from Germany. I chose studying computer science because I love building things. I am of the opinion that there isn’t one truth (especially for computer science concepts) and whoever claims so isn’t that trustworthy in my eyes. I constantly try to improve things and myself. In my spare time I support businesses by offering them most of my services for free. Beside that I am kind of addict to e-learning courses.