If you create scripts in Windows, editors sometimes add a carriage return in addition to the line feed.
You can use dos2unix to remove the extra characters. Or you can use sed.
sed -i -e 's/\r$//' script.sh |
cloud engineer
If you create scripts in Windows, editors sometimes add a carriage return in addition to the line feed.
You can use dos2unix to remove the extra characters. Or you can use sed.
sed -i -e 's/\r$//' script.sh |
sed -i -e 's/\r$//' script.sh
In Windows a new line, is a CR (carriage return) followed by LF (line feed). In Linux, it’s just LF. If you bring over a text file from Windows to Linux, sometimes you’ll end up with a file with a bunch of ^M at the end of each line, which will breaks a lot of things. To fix, just run dos2unix.
dos2unix file.txt |
dos2unix file.txt