Unix dos2unix examples 


June 21, 2011 08:32:15    Last update: June 21, 2011 08:32:15
The Dos2unix package includes utilities "dos2unix" and "unix2dos" to convert plain text files in DOS or MAC format to UNIX format and vice versa.
  1. By default, it replaces the original file:
    $ dos2unix base64_encoded.txt 
    dos2unix: converting file base64_encoded.txt to UNIX format ...

  2. Use the -n switch to write the converted output to a new file:
    $ dos2unix -n base64_encoded.txt unix_formatted.txt
    dos2unix: converting file base64_encoded.txt to file unix_formatted.txt in UNIX format ...

  3. Using STDOUT (-) as output file does not work:
    $ dos2unix -n base64_encoded.txt -

  4. Use input redirection to write to STDOUT:
    $ dos2unix < base64_encoded.txt

Share |
| Comment  | Tags