내용으로 건너뛰기
adminschool.net wiki
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
os:debian:lineconvert
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== Convert DOS (or Windows) and Mac text files to Unix, or vice-verca ====== I tried to open windows text files in Mandriva, but there seems to be a problem with the end of line... How do I fix this?! Figure 1: Start the KonsoleCommon problem! If you need to exchange text files between DOS/Windows, Mac, and Linux, be aware of the "end of line" problem. Under DOS, each line of text ends with CR/LF (that is, ASCII 13 + ASCII 10), with LF under Linux. If you edit a DOS text file under Linux, each line will likely end with a strange--looking `M' character; a Linux text file under DOS will appear as a kilometric single line with no paragraphs... Most linux programs that I use do the correction automatically, but there might still be some old programs around that do not know how to deal with this... For instance, I noticed that it can be a problem with input files to a fortran program. Same goes for windows, most programs will know how to deal with it, but you still find programs that get confused, and notepad is one of them. Anyway, under Mandriva, the fix is easy! Simply install <code> unix2dos </code> and <code> dos2unix </code> When you want to convert a windows text file to unix, open a console (Figure 1), move into the proper directory, and type <code> dos2unix the_file_I_want_to_convert.txt </code> To convert a unix text file to windows, open a console, move into the proper directory, and type <code> unix2dos the_file_I_want_to_convert.txt </code> Actually, those programs are quite easy to write, usually a one liner in Perl! So while I'm at it, here they are... This script will perform a conversion from unix to dos: <code> #!/usr/bin/perl -pi s/\n/\r\n/; </code> Save it as unix2dos.pl, make it executable (chmod a+x unix2dos.pl) and you're all set. Here is the code for dos2unix.pl <code> #!/usr/bin/perl -pi s/\r\n/\n/; </code> And for those who have to deal with Macs, we have mac2unix.pl: <code> #!/usr/bin/perl -pi.unix s/\r/\n/g; </code> and unix2mac.pl: <code> #!/usr/bin/perl -pi.unix s/\n/\r/g; </code> Now, you should be all set with you text files! * [펌] http://soft.zoneo.net/Linux/dos_to_unix.php
os/debian/lineconvert.txt
· 마지막으로 수정됨: 2007/08/13 00:11 저자
222.238.62.148
문서 도구
문서 보기
이전 판
역링크
맨 위로