Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

linux - How to use 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

If you are using a Debian-based distro, you should be able to do sudo apt-get 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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...