Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-04-2009, 09:42 AM   #1
LQ Newbie
Registered: Oct 2009
Posts: 5

Rep: Reputation: 0

I am using Ubuntu with kernel I am not finding dos2unix.
Can you please help me about how I can install this from any source or any equivalent one for dos2unix. Or any solution to remove "^M" character in the source files that I want to compile now.
-KDB Learner
Old 10-04-2009, 11:10 AM   #2
Registered: Nov 2003
Distribution: Ubuntu
Posts: 218

Rep: Reputation: 46
sudo apt-get install tofrodos
check man tofrodos for how to use it. It looks about the same as dos2unix which I did not find in the repository.
Old 10-04-2009, 11:11 AM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036Reputation: 2036
There's a tool similar to it called flip available in the debian repositories, so it's probably also in *buntu.

You can also simply use sed to convert the line endings. This page includes the proper code (about one page down), along with many other useful one-liners.
Old 10-04-2009, 12:03 PM   #4
LQ Newbie
Registered: Oct 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks to ajlewis2 and David the H.
I got the solution now. I installed sudo apt-get install tofrodos. Also doing the "man tofrodos" gave me the two commands "fromdos" and "todos". Using "todos -f * *", I was able fix the "^M" issue in all the files in a directory.
Old 10-04-2009, 12:08 PM   #5
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
It looks like it's in package tofrodos in debian.

# apt-get install tofrodos

$ apt-file find dos2unix

Assuming that apt-file is installed and updated.

# apt-get install apt-file
# apt-file update

dos2unix and unix2dos just change the 0x0D0A to 0x0A and similar. Because the OS's differ in how text files end their lines. 0x0D is carraige return. And 0x0A is linefeed. \r\n for echo commands and the likes. I don't quite recall which is which by a quick echo to a file and hexedit / hexdump should show that detail. It's a printer thing. Back when you typed things on mechanical devices. There was one way to bring the roll back to the start of the line, and nother to feed the paper up a line. Carraige return and line feed. Dos/windows does 0x0D0A, *nix does 0x0A, and Mac does 0x0D or something like that. I probably got something changed around in there somewhere. And it's part of the reason that you have to tell ftp clients which transfer mode (binary/ascii) when getting data from that method. So that the ftp client can do the dos2unix / unix2dos conversion for you on text files. Based on what it thinks your client / platform is.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
convert dos2unix /opt/SV DC/*.* using system command.Here path is having space. nagendrar Linux - Newbie 1 08-06-2009 06:27 AM
dos2unix - problems renaming tmpfile to outfile Linux - General 5 12-31-2008 06:25 AM
Use of dos2unix command Karthikeyan Gurusamy Linux - Newbie 3 02-02-2006 07:32 AM
dos2unix command on a folder raghunandan Linux - Software 1 12-12-2005 08:50 AM
dos2unix package alaios Debian 1 01-16-2005 07:41 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration