---
title: "很多^M在代码行的后面"
author: "夜鸣猪"
date: "2012-04-06T05:11:18Z"
tags: []
categories: ["编程语言"]
slug: "m"
draft: false
lastmod: "2012-04-06T05:49:44Z"
id: 1476195
url: "https://hlee.iteye.com/blog/1476195"
---

在git diff的时候发现
可能是Windows开发工具搞上来的，因为有不一样的换行回车
解决办法是

```java

vim
:set fileformat=unix
:%s/^M//g
:%s/\r//g

:w

```



> dos2unix
> 
> perl -pie 's/\r//g' filename.txt
> 




```shell

sed s/\r// hello.txt > helloUNIX.txt
dos2unix hello.txt helloUNIX.txt
cat hello.txt | tr -d \r > helloUNIX2.txt


```