\u4f60\u53ef\u80fd\u4f1a\u5728\u5b89\u88c5\u65f6\u9047\u5230\u9ebb\u70e6\uff0c\u4f46 dos2unix \u53ef\u80fd\u662f\u5c06 Windows \u6587\u672c\u8f6c\u6362\u4e3a Unix\/Linux \u6587\u672c\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u3002\u4e00\u4e2a\u547d\u4ee4\u5e26\u4e0a\u4e00\u4e2a\u53c2\u6570\u5c31\u884c\u4e86\u3002\u4e0d\u9700\u8981\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u540d\u3002\u8be5\u6587\u4ef6\u4f1a\u88ab\u76f4\u63a5\u66f4\u6539\u3002<\/p>\n
$ dos2unix testfile.txt\r\ndos2unix: converting file testfile.txt to Unix format...<\/pre>\n\u4f60\u5e94\u8be5\u4f1a\u53d1\u73b0\u6587\u4ef6\u957f\u5ea6\u51cf\u5c11\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5b83\u5305\u542b\u7684\u884c\u6570\u3002\u5305\u542b 100 \u884c\u7684\u6587\u4ef6\u53ef\u80fd\u4f1a\u7f29\u5c0f 99 \u4e2a\u5b57\u7b26\uff0c\u56e0\u4e3a\u53ea\u6709\u6700\u540e\u4e00\u884c\u4e0d\u4f1a\u4ee5 CRLF \u5b57\u7b26\u7ed3\u5c3e\u3002<\/p>\n
\u4e4b\u524d\uff1a<\/p>\n
-rw-rw-r-- 1 shs shs 121 Sep 14 19:11 testfile.txt<\/pre>\n\u4e4b\u540e\uff1a<\/p>\n
-rw-rw-r-- 1 shs shs 118 Sep 14 19:12 testfile.txt<\/pre>\n\u5982\u679c\u4f60\u9700\u8981\u8f6c\u6362\u5927\u91cf\u6587\u4ef6\uff0c\u4e0d\u7528\u6bcf\u6b21\u4fee\u590d\u4e00\u4e2a\u3002\u76f8\u53cd\uff0c\u5c06\u5b83\u4eec\u5168\u90e8\u653e\u5728\u4e00\u4e2a\u76ee\u5f55\u4e2d\u5e76\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n
$ find . -type f -exec dos2unix {} \\;<\/pre>\n\u5728\u6b64\u547d\u4ee4\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 find \u67e5\u627e\u5e38\u89c4\u6587\u4ef6\uff0c\u7136\u540e\u8fd0\u884c dos2unix \u547d\u4ee4\u4e00\u6b21\u8f6c\u6362\u4e00\u4e2a\u3002\u547d\u4ee4\u4e2d\u7684 {} \u5c06\u88ab\u66ff\u6362\u4e3a\u6587\u4ef6\u540d\u3002\u8fd0\u884c\u65f6\uff0c\u4f60\u5e94\u8be5\u5904\u4e8e\u5305\u542b\u6587\u4ef6\u7684\u76ee\u5f55\u4e2d\u3002\u6b64\u547d\u4ee4\u53ef\u80fd\u4f1a\u635f\u574f\u5176\u4ed6\u7c7b\u578b\u7684\u6587\u4ef6\uff0c\u4f8b\u5982\u9664\u4e86\u6587\u672c\u6587\u4ef6\u5916\u5728\u4e0a\u4e0b\u6587\u4e2d\u5305\u542b\u516b\u8fdb\u5236 15 \u7684\u6587\u4ef6\uff08\u5982\uff0c\u955c\u50cf\u6587\u4ef6\u4e2d\u7684\u5b57\u8282\uff09\u3002<\/p>\n
sed<\/strong><\/span><\/div>\n\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6d41\u7f16\u8f91\u5668 sed \u6765\u5220\u9664\u56de\u8f66\u7b26\u3002\u4f46\u662f\uff0c\u4f60\u5fc5\u987b\u63d0\u4f9b\u7b2c\u4e8c\u4e2a\u6587\u4ef6\u540d\u3002\u4ee5\u4e0b\u662f\u4f8b\u5b50\uff1a<\/p>\n
$ sed -e \u201cs\/^M\/\/\u201d before.txt > after.txt<\/pre>\n\u4e00\u4ef6\u9700\u8981\u6ce8\u610f\u7684\u91cd\u8981\u7684\u4e8b\u60c5\u662f\uff0c\u8bf7\u4e0d\u8981\u8f93\u5165\u4f60\u770b\u5230\u7684\u5b57\u7b26\u3002\u4f60\u5fc5\u987b\u6309\u4e0b Ctrl+V \u540e\u8ddf Ctrl+M \u6765\u8f93\u5165 ^M\u3002s \u662f\u66ff\u6362\u547d\u4ee4\u3002\u659c\u6760\u5c06\u6211\u4eec\u8981\u67e5\u627e\u7684\u6587\u672c\uff08Ctrl + M\uff09\u548c\u8981\u66ff\u6362\u7684\u6587\u672c\uff08\u8fd9\u91cc\u4e3a\u7a7a\uff09\u5206\u5f00\u3002<\/p>\n
vi<\/strong><\/span><\/div>\n\u4f60\u751a\u81f3\u53ef\u4ee5\u4f7f\u7528 vi \u5220\u9664\u56de\u8f66\u7b26\uff08Ctrl+M\uff09\uff0c\u4f46\u8fd9\u91cc\u5047\u8bbe\u4f60\u6ca1\u6709\u6253\u5f00\u6570\u767e\u4e2a\u6587\u4ef6\uff0c\u6216\u8bb8\u4e5f\u5728\u505a\u4e00\u4e9b\u5176\u4ed6\u7684\u4fee\u6539\u3002\u4f60\u53ef\u4ee5\u952e\u5165 : \u8fdb\u5165\u547d\u4ee4\u884c\uff0c\u7136\u540e\u8f93\u5165\u4e0b\u9762\u7684\u5b57\u7b26\u4e32\u3002\u4e0e sed \u4e00\u6837\uff0c\u547d\u4ee4\u4e2d ^M \u9700\u8981\u901a\u8fc7 Ctrl+V \u8f93\u5165 ^\uff0c\u7136\u540e Ctrl+M \u63d2\u5165 M\u3002%s \u662f\u66ff\u6362\u64cd\u4f5c\uff0c\u659c\u6760\u518d\u6b21\u5c06\u6211\u4eec\u8981\u5220\u9664\u7684\u5b57\u7b26\u548c\u6211\u4eec\u60f3\u8981\u66ff\u6362\u5b83\u7684\u6587\u672c\uff08\u7a7a\uff09\u5206\u5f00\u3002 g\uff08\u5168\u5c40\uff09\u610f\u5473\u5728\u6240\u6709\u884c\u4e0a\u6267\u884c\u3002<\/p>\n
:%s\/^M\/\/g<\/pre>\n\u603b\u7ed3<\/strong><\/div>\ndos2unix \u547d\u4ee4\u53ef\u80fd\u662f\u6700\u5bb9\u6613\u8bb0\u4f4f\u7684\uff0c\u4e5f\u662f\u4ece\u6587\u672c\u4e2d\u5220\u9664\u56de\u8f66\u7684\u6700\u53ef\u9760\u7684\u65b9\u6cd5\u3002\u5176\u4ed6\u9009\u62e9\u4f7f\u7528\u8d77\u6765\u6709\u70b9\u56f0\u96be\uff0c\u4f46\u5b83\u4eec\u63d0\u4f9b\u76f8\u540c\u7684\u57fa\u672c\u529f\u80fd\u3002<\/p>\n
via: https:\/\/www.networkworld.com\/article\/3438857\/how-to-remove-carriage-returns-from-text-files-on-linux.html<\/p>\n
\u4f5c\u8005\uff1aSandra Henry-Stocker \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1ageekpi \u6821\u5bf9\uff1awxy<\/p>\n
\u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"
\u4ed6\u4eec\u5728 Windows \u4e0a\u7684\u6587\u672c\u6587\u4ef6\u4e0a\u4fdd\u7559\u4e86\u5b83\uff0c\u4f46\u4ece\u672a\u5728 Linux \u7cfb\u7edf\u4e0a\u4f7f\u7528\u8fc7\u3002\u5f53\u4f60\u5c1d\u8bd5\u5728 Linux \u4e0a […]<\/p>\n","protected":false},"author":1482,"featured_media":133028,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-159677","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/159677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=159677"}],"version-history":[{"count":6,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/159677\/revisions"}],"predecessor-version":[{"id":159769,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/159677\/revisions\/159769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/133028"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=159677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=159677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=159677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}