---
title: "UNIX / Linux Convert DOS Newlines CR-LF to Unix/Linux Format"
author: "marlgl"
date: "2011-09-22T18:48:37Z"
tags: []
categories: ["操作系统"]
slug: "unix-linux-convert-dos-newlines-cr-lf-to-unix-linux-format"
draft: false
lastmod: "2011-09-22T18:48:37Z"
id: 1178321
url: "https://marlgl.iteye.com/blog/1178321"
---

patch remove Bomb(^M) 


```java
 $ cat ~/bin/rmBom 

#! /bin/sh¬
¬
#echo "uconv --remove-signature the $1 files"¬
¬
### uconv not availble¬
#    find . -name "*.$1" \¬
#    -exec uconv --remove-signature {} -o {}.nobom \; \¬
#    -exec mv {}.nobom {} \;¬
¬
### ¬
# Convert DOS newlines (CR/LF) to Unix format using sed command¬
#¬
echo "Convert DOS newlines (CR/LF) to Unix format using sed command."¬
echo "sed 's/^M$//' $1 files ..."¬
¬
find . -name "*.$1" \¬
         -exec bash -c "sed 's/^M$//' {} > {}.sed;mv {}.sed {}" \;¬


```


[HowTo: UNIX / Linux Convert DOS Newlines CR-LF to Unix/Linux Format](http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/)