shell crlf to lf
UNIX/Linux Commands
You can use the following tools:
- dos2unix (also known as fromdos) – converts text files from the DOS format to the Unix
format - unix2dos (also known as todos) – converts text files from the Unix format to the DOS format.
- sed – You can use sed command for same purpose
- tr command
- Perl one liner
Task: Convert DOS file to UNIX format
Type the following command to convert file called myfile.txt:$ dos2unix myfile.txt
However above command will not make a backup of original file myfile.txt. To make a backup of original file. The original file is renamed with the original filename and a .bak extension. Type the following command:$ dos2unix -b myfile.txt
Task: Convert UNIX file to DOS format
Type the following command to convert file called myfile.txt:$ unix2dos myfile.txt
$ unix2dos -b myfile.txt
Task: Convert Dos TO Unix Using tr Command
Type the following command:
tr -d '\r' < input.file > output.file |
Task: Convert Dos TO Unix Using Perl One Liner
Type the following command:
perl -pi -e 's/\r\n/\n/g' input.file |
Task: Convert UNIX to DOS format using sed command
Type the following command if you are using bash shell:$ sed 's/$'"/`echo \\\r`/" input.txt > output.txt
Note: sed version may not work under different UNIX/Linux variant,refer your local sed man page for more info.
Task: Convert DOS newlines (CR/LF) to Unix format using sed command
If you are using BASH shell type the following command (press Ctrl-V then Ctrl-M to get pattern or special symbol)$ sed 's/^M$//' input.txt > output.txt
Note: sed version may not work under different UNIX/Linux variant, refer your local sed man page for more info.
shell crlf to lf的更多相关文章
- 趣谈、浅析CRLF和LF
作为程序员,在处理文件和输入输出的时候经常要跟CRLF和LF打交道.可能大家多少知道一些,但总是记不清楚,我也是这样的,因此写下这篇博文,作为记录. 首先,明确他们的意思:CR(回车),LF(换行). ...
- eslint 关于CRLF或者LF报错
在拉取项目代码时,如果有eslint代码校验,但是本地打开会有于CRLF或者LF报错报错,那么怎么处理呢? git有个自动转换换行符功能,在文件commit时会自动转换换行符格式: 不想使用,也可以通 ...
- Git 换行符检查 CRLF 与 LF
遇到的问题 在 git 提交或是签出时,提示如下问题: [git] warning: LF will be replaced by CRLF | fatal: CRLF would be replac ...
- [git] warning: LF will be replaced by CRLF | fatal: CRLF would be replaced by LF[ git 处理和修改行结束符(CRLF和LF)]
我自己的设置是: [core] autocrlf = false[core] safecrlf = true 取消自动转换CRLF(上图中选的是commit as is),但是有提交前混用检查 本人用 ...
- 解决crlf 和 lf不同带来的冲突问题
crlf 和 lf 是文本换行的不同方式: crlf: "\r\n", windows系统的换行方式 lf: "\n", Linux系统的换行方式 他们之间的不 ...
- CRLF和LF
协作项目,开发环境不同(mac,window)构建过程中,命令行报错(expecting LF but only find CRLF) 打开git bash,输入 $ git config --glo ...
- Git操作中crlf和lf冲突问题
多人参与项目开发的时候,经常会遇到代码格式化不一致,在提交的时候出现很多冲突的情况.其中换行符冲突就是一种,在不同的系统平台上是不一样的.UNIX/Linux 使用的是 0x0A(LF),早期的 Ma ...
- CRLF与LF解析
window和mac的同学合作开发项目,会出现git提交/拉取时换行符不一致导致,提示 "the text is identical, but the files do not match, ...
- Notepad++ 替换 CRLF 为 LF
对于文件中每一行的结尾符号,Windows 下默认为 CRLF,而 Unix 下默认为 LF. 所以经常会有这样的情况发生:在 Windows 系统下编辑的文件放在 Unix 下不能正常执行,比如 b ...
随机推荐
- Confluence 6 升级自定义的站点和空间布局
随着 Confluence 的演变.默认的站点和空间布局也会随着 Confluence 升级而让使用的所有页面进行改变.随着一些新功能的加入和一些老功能的修改,默认的布局也需要进行修改来支持这些改变. ...
- nginx实战(三)之静态资源web服务(跨站访问)
语法 虽然说浏览器禁止跨站访问以防(CSRF),但出于一些原因还是要进行跨站访问,服务端通过设置头信息Access-Control-Allow-Orign:xxxx,客户端收到后就会允许跨站访问了 实 ...
- ActiveMQ消息的发送原理
持久化消息和非持久化消息的发送策略:消息同步发送和异步发送 ActiveMQ支持同步.异步两种发送模式将消息发送到broker上.同步发送过程中,发送者发送一条消息会阻塞直到broker反馈一个确认消 ...
- 论文阅读笔记十一:Rethinking Atrous Convolution for Semantic Image Segmentation(DeepLabv3)(CVPR2017)
论文链接:https://blog.csdn.net/qq_34889607/article/details/8053642 摘要 该文重新窥探空洞卷积的神秘,在语义分割领域,空洞卷积是调整卷积核感受 ...
- python函数之各种器
一: 装饰器 1:装饰器模板 def wrapper(func): def inner(*args,**kwargs): ret =func(*args,**kwargs) return ret re ...
- 利用SVD-推荐未尝过的菜肴2
推荐未尝过的菜肴-基于SVD的评分估计 实际上数据集要比我们上一篇展示的myMat要稀疏的多. from numpy import linalg as la from numpy import * d ...
- 正则 ?<= 和 ?= 用法,范例
(exp) 匹配exp,并捕获文本到自动命名的组里(?<name>exp) 匹配exp,并捕获文本到名称为name的组里,也可以写成(?'name'exp)(?:exp) 匹配exp,不捕 ...
- 如何下载kubenetes最新的rpm包?
一,新增aliyun的软件仓库 tee /etc/yum.repos.d/kubernetes.repo <<-'EOF' [kubernetes] name=Kubernetes bas ...
- linux 出错 “INFO: task xxxxxx: 634 blocked for more than 120 seconds.”的3种解决方案
https://blog.csdn.net/electrocrazy/article/details/79377214
- TagCanvas 插件
TagCanvas是一个基于HTML5 Canvas技术开发的标签云动画.还提供一个以jQuery插件形式实现的版本. 它支持文本和图片两种格式,能够以Sphere, hcylinder 或 vcyl ...