dos2unix bash script

 

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'

 

 Line number 1 tells your system that this file is a set of commands that will be executed by the bash CLI.

Line number 2 convert from dos to unix

 

save this file as d2u.sh and exit from gedit

from a terminal set the file execution attribute typing 

# chmod +x d2u.sh

and move it into /usr/local/bin

# mv d2u.sh /usr/local/bin

now the script is ready to run.

 

Try this script typing the following command:

# d2u.sh <dos_file_name>

 
Posted by at April 20, 2009
Filed in category: Bash Tip & Tricks, and tagged with: ,

One Response to dos2unix bash script

  1. Pingback: xAppSoftware » dos2unix bash script - part two

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

Statistical data collected by Statpress SEOlution (blogcraft).