码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • dos2unix命令


    dos2unix是将Windows格式文件转换为Unix、Linux格式的实用命令。Windows格式文件的换行符为\r\n ,而Unix&Linux文件的换行符为\n. dos2unix命令其实就是将文件中的\r\n 转换为\n。

    而unix2dos则是和dos2unix互为孪生的一个命令,它是将Linux&Unix格式文件转换为Windows格式文件的命令。
    安装:

    yum install -y dos2unix
    
    yum install -y unix2dos
    
    • 1
    • 2
    • 3

    命令用法:

    dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
    
    unix2dos [options] [-c convmode] [-o file ...] [-n infile outfile ...]
    
    • 1
    • 2
    • 3

    示例:
    最简单的用法就是dos2unix直接跟上文件名:

    [root@cdn weihu]# dos2unix customer.yaml
    dos2unix: converting file customer.yaml to Unix format...
    
    • 1
    • 2

    如果一次转换多个文件,把这些文件名直接跟在dos2unix之后。(注:也可以加上-o参数,也可以不加,效果一样)

    [root@cdn weihu]# dos2unix  01-crd-all.gen.yaml  02-istio.yaml  customer.yaml
    dos2unix: converting file 01-crd-all.gen.yaml to Unix format...
    dos2unix: converting file 02-istio.yaml to Unix format...
    dos2unix: converting file customer.yaml to Unix format...
    [root@cdn weihu]#
    [root@cdn weihu]#
    [root@cdn weihu]# dos2unix -o  01-crd-all.gen.yaml  02-istio.yaml  customer.yaml
    dos2unix: converting file 01-crd-all.gen.yaml to Unix format...
    dos2unix: converting file 02-istio.yaml to Unix format...
    dos2unix: converting file customer.yaml to Unix format...
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    上面在转换时,都会直接在原来的文件上修改,如果想把转换的结果保存在别的文件,而源文件不变,则可以使用-n参数。

    [root@cdn weihu]# dos2unix -n customer.yaml  customer-test.yaml
    dos2unix: converting file customer.yaml to file customer-test.yaml in Unix format...
    [root@cdn weihu]#
    [root@cdn weihu]# ll
    total 412
    -rw-r--r--. 1 root root 275632 Nov 21 09:41 01-crd-all.gen.yaml
    -rw-r--r--. 1 root root 133119 Nov 21 09:41 02-istio.yaml
    -rw-r--r--. 1 root root    953 Nov 21 09:42 customer-test.yaml
    -rw-r--r--. 1 root root    953 Nov 21 09:41 customer.yaml
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  • 相关阅读:
    机器学习扫盲:优化算法、损失函数、评估指标、激活函数、网络架构
    10月30日,深圳见!51camera与您相约机器视觉展
    第五篇、Callable接口实现多线程
    时间戳的理解
    学生个人网页设计作品:基于HTML+CSS+JavaScript实现摄影艺术网站 DIV布局简单的摄影主题网站
    一篇够用的TypeScript总结(包含面试题及答案收录)
    SpringBoot整合MongoDB
    使用nodel实现前后端数据渲染
    layui控件开发,实现下拉搜索从数据库获取数据
    【JavaEE】多线程(Part3线程安全)
  • 原文地址:https://blog.csdn.net/weixin_45432833/article/details/134524080
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号