Any command we can use to convert windows file to

2019-09-17 16:02发布

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?

标签: linux perl
3条回答
对你真心纯属浪费
2楼-- · 2019-09-17 16:38

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

查看更多
对你真心纯属浪费
3楼-- · 2019-09-17 16:57

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.

查看更多
Evening l夕情丶
4楼-- · 2019-09-17 16:59

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
查看更多
登录 后发表回答