• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

line feed

Dos2unix Alternative

July 2, 2021

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

Filed Under: Linux Tagged With: carriage return, characters, dos2unix, extra, line feed

Dos2unix

September 18, 2020

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

Filed Under: Linux Tagged With: carriage return, convert, cr, dos2unix, lf, line feed

  • Home
  • About
  • Archives

Copyright © 2023