Linux 我们可以使用任何命令将windows文件转换为unix或mac文件吗?

Linux 我们可以使用任何命令将windows文件转换为unix或mac文件吗?,linux,perl,Linux,Perl,我不想使用dos2unix工具。我想使用Ubuntu终端中的命令将Windows文件转换为Unix文件。那有可能吗。我已经阅读了其他文章,并尝试了这些命令,但都不起作用。有人可以帮忙吗?您可以使用tr删除回车,如下所示: tr -d '\r' < WindowsFile > UnixFile 要查看您的文件中是否有回车符,对于Ubuntu(和Debian),它们将显示为^M,您可以使用tofrodos软件包 sudo aptitude install tofrodos fromdo

我不想使用dos2unix工具。我想使用Ubuntu终端中的命令将Windows文件转换为Unix文件。那有可能吗。我已经阅读了其他文章,并尝试了这些命令,但都不起作用。有人可以帮忙吗?

您可以使用
tr
删除回车,如下所示:

tr -d '\r' < WindowsFile > UnixFile
要查看您的文件中是否有回车符,对于Ubuntu(和Debian),它们将显示为
^M

,您可以使用tofrodos软件包

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(作为UNIX的衍生物)应该与UNIX具有相同的行尾

如果你在Windows上,你可以找到

如果您在Mac上,您可以使用软件包管理器在OSX上安装

我想使用Ubuntu终端中的命令将Windows文件转换为Unix文件

我不想使用dos2unix工具


为什么不想使用dos2unix,这是专门为此目的而构建的工具?我在windows中使用Activestate Perl,我的Perl脚本在windows中运行良好,但我需要使此脚本在MAC上工作。所以我在我的pendrive中安装了Ubuntu,并从那里开始工作。我无法安装dos2unix,因此我正在寻找是否有任何方法可以仅使用terminal命令将windows文件转换为unix文件?它没有转换文件。@JS웃, 如果一个人没有明确说明为什么他不想使用某些东西,那么我们如何判断什么是合适的替代品呢?据我们所知,他不喜欢这个名字。更糟糕的是,我们之所以想要避免这种情况,是因为有些东西通常是有缺陷的,有些东西我们可以帮助(例如安装模块)。这让我大笑起来+1
sudo aptitude install tofrodos
fromdos file.txt # converts the file to UNIX line-endings
todos   file.txt # converts the file to Windows line-endings
dos2unix path/to/file/to/convert
alias notdos2unix=dos2unix

notdos2unix path/to/file/to/convert