Archive

Posts Tagged ‘dos2unix’

dos2unix bash script – part two

May 9th, 2009 gg1 No comments

In this article I’ll show you a more complex script than the script I have shown in the article dos2unix bash script. This new script allow you to convert more than one file at the same time.

dos2unix using vim [part 2]- How to remove ^M chars from a DOS file

April 26th, 2009 gg1 No comments

Vim (vi improved) provides a rapid way to change the format from dos to unix and viceversa.

After you have opened your text file, just type the following command in vim:

:set fileformat=unix

to change the format to unix, or type:

:set fileformat=dos

dos2unix bash script

April 20th, 2009 gg1 No comments

 

In this article I will show you a short bash script that will do a dos2unix text file conversion.

edit a new file with gedit
 
insert the following line:

1:   #!/bin/bash
2:   cat $1|tr -d '\015'

Categories: Bash Tip & Tricks Tags: ,

dos2unix using sed – How to remove ^M chars from a DOS file

April 9th, 2009 gg1 No comments

After dos2unix using vim, here is dos2unix using sed

 

in bash you could type the following command:

# sed 's/^M$//' input.txt > output.txt

or  you can convert UNIX to DOS by typing the following command:

# sed 's/$'"/`echo \\\r`/" input.txt > output.txt

Categories: Bash Tip & Tricks, linux Tags: , ,

dos2unix using vi or vim – How to remove ^M chars from a DOS file

March 31st, 2009 gg1 No comments

Often I need to translate source code from dos/windows format to UNIX format, MS-DOS and WINDOWS use a <carriage return>-<line feed> combination to represent end of line char while UNIX uses only a <line feed>.