How to use dos2unix?

You should be able to get dos2unix from your package manager on Linux.

If you are using a Debian-based distro, you should be able to do sudo apt-get install dos2unix.

If you are using a RH-like distro, you should be able to do sudo yum install dos2unix.

Once it is installed, you can just give the target file as an argument'

dos2unix test.pl

Also, note that this may not be the only problem you might run into while trying to move a script to Linux from Windows.

For example, if you are invoking any external tools in your script, those tools will probably have different names or not exist at all on the other platform.

Also, if you are using any relative file paths with path separators, the separator is different on Linux (which uses /) than Windows (which uses \).


Another option would be to use a text editor on windows that supports UNIX line endings.

Which text editors handle both Windows- and Unix-style line breaks properly?

Tags:

Linux

Perl