SSh
SSh

Reputation: 157

Any command we can use to convert windows file to unix or mac file?

I don't want to use dos2unix tool. I want to use command in Ubuntu terminal to convert Windows file to Unix file. Is that possible. I have looked through other articles and tried those commands but none working. Anyone can help?

Upvotes: 0

Views: 2601

Answers (3)

ikegami
ikegami

Reputation: 386396

I want to use command in Ubuntu terminal to convert Windows file to Unix file.

dos2unix path/to/file/to/convert

I don't want to use dos2unix tool.

alias notdos2unix=dos2unix

notdos2unix path/to/file/to/convert

Upvotes: 4

Mark Setchell
Mark Setchell

Reputation: 207678

You can use tr to remove carriage returns like this:

tr -d '\r' < WindowsFile > UnixFile

You can use

cat -vet WindowsFile

to see if there are carriage returns in your file and they'll show up as ^M

Upvotes: 4

wsdookadr
wsdookadr

Reputation: 2672

For Ubuntu(and Debian) you can use the tofrodos package.

sudo aptitude install tofrodos
fromdos file.txt # converts the file to UNIX line-endings
todos   file.txt # converts the file to Windows line-endings

OSX (being a derivative of UNIX) should have the same line-endings as UNIX.

If you're on Windows, you can find tofrodos binaries here.

If you're on a Mac, you can use the brew package manager and install the tofrodos on OSX.

Upvotes: 3

Related Questions