如何使用dos2unix? [英] How to use dos2unix?

查看:127
本文介绍了如何使用dos2unix?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习perl编程.我已经在Windows平台上运行了perl脚本,但是我需要在Linux平台(如Ubuntu)中运行它.我的脚本可以在Windows中完美运行,但不能在Linux中完美运行.我不熟悉dos2unix工具.我正在努力在Windows 7中使用它以及如何将Winfile转换为unixfile.假设我的perl脚本是test.pl,并且其中包含编码.现在如何使用dos2unix工具使此脚本在Linux中正常工作?此外,我应该在哪里解压缩dos2unix工具?

I am learning perl programming. I have run a perl script in windows platform but I need to run it in Linux platform like in Ubuntu. My script run perfectly in windows but not in Linux. I am not familiar with dos2unix tool. I am struggling about how to use it in my windows 7 and how to convert my winfile to unixfile. Suppose my perl script is test.pl and coding are inside. Now how can I make this script work properly in Linux using dos2unix tool? Besides, where should I unzip dos2unix tool?

推荐答案

您应该能够从Linux上的程序包管理器中获取dos2unix.

You should be able to get dos2unix from your package manager on Linux.

如果您使用的是基于Debian的发行版,则应该可以执行sudo apt-get install dos2unix.

If you are using a Debian-based distro, you should be able to do sudo apt-get install dos2unix.

如果您使用的是类似RH的发行版,则应该可以执行sudo yum install dos2unix.

If you are using a RH-like distro, you should be able to do sudo yum install dos2unix.

安装完成后,您只需将目标文件作为参数即可.

Once it is installed, you can just give the target file as an argument'

dos2unix test.pl

此外,请注意,这可能不是您尝试将脚本从Windows迁移到Linux时遇到的唯一问题.

Also, note that this may not be the only problem you might run into while trying to move a script to Linux from Windows.

例如,如果您在脚本中调用任何外部工具,则这些工具可能具有不同的名称,或者在其他平台上根本不存在.

For example, if you are invoking any external tools in your script, those tools will probably have different names or not exist at all on the other platform.

此外,如果您使用任何带有路径分隔符的相对文件路径,则Linux(使用/)上的分隔符与Windows(使用\)上的分隔符不同.

Also, if you are using any relative file paths with path separators, the separator is different on Linux (which uses /) than Windows (which uses \).

这篇关于如何使用dos2unix?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆