Posts Tagged ‘hidden characters’

Linux – Dos2Unix – Convert DOS/MAC files to Unix

If you have created files using Notepad or suchlike on a windows system there is a likelihood that when you transfer it to a unix/linux environment that the file will contain extra hidden characters such as ^M and ^r.

In order to remove these you can use the dos2unix function if it is installed on your operating system.


dos2unix <filename>

This command will convert the plain text file into a format compatible with Unix.


-k --keepdate

If this flag is set then the output file will have the same datestamp as the input file.

-q --quiet

This flag suppresses all warning messages. Quiet mode.

-V --version

This prints version information.

-c --convmode convmode

Sets conversion mode. Where convmode is one of: ASCII, 7bit, ISO, Mac with ASCII being the default. Simulates dos2unix under SunOS.

-O --oldfile file...

Old file mode. Convert the file and write output to it, therefore overwriting the file. This is the default option for dos2unix

-n --newfile infile outfile...

New file mode. This converts the infile and writes output to outfile. Do not use wildcards as this will lose your file. File names must be given in pairs.