Fishpond 604x90

Thursday, December 08, 2005

How to transform dos file to unix file?

We know that windoz and unix save files with different endings for each line. If you write a shell script under windoz, it will not work under unix. It may shows ": command not found" on the command line. To solve this problem, we need to change the file format. An easy way to do this is:

$ tr '\r\n' '\n' < dosfile > unixfile

This will replace all the '\r\n' at the end of each line with '\n'.

2 comments:

ZHU Xin Hao said...

we need new poster

Anonymous said...

Hi, Buddy, I usually do it in another way

perl -pi -e"s/\r\n/\n/g" youfile