zoukankan      html  css  js  c++  java
  • shell脚本,当用sed删除某一文件里面的内容时,并追加到同一个文件会出现问题。

    shell脚本,当用sed删除某一文件里面的内容时,并追加到同一个文件会出现问题。
    因为初始文件和写入文件是一个文件这是失败的。需要追加到另一个文件,然后再用mv进行操作。
    [root@localhost wyb]# seq 10 > 10.txt [root@localhost wyb]# cat 10.txt 1 2 3 4 5 6 7 8 9 10 [root@localhost wyb]# cat 10.txt |sed '1,5d' 6 7 8 9 10 [root@localhost wyb]# cat 10.txt |sed '1,5d' >10.txt [root@localhost wyb]# cat 10.txt [root@localhost wyb]# seq 10 >10.txt [root@localhost wyb]# cat 10.txt 1 2 3 4 5 6 7 8 9 10 [root@localhost wyb]# cat 10.txt |sed '1,5d' >11.txt [root@localhost wyb]# cat 11.txt 6 7 8 9 10 [root@localhost wyb]# mv 11.txt 10.txt mv: overwrite `10.txt'? y [root@localhost wyb]# cat 10.txt 6 7 8 9 10 [root@localhost wyb]#
  • 相关阅读:
    Django ORM 之F、Q查询与事务
    Django ORM 之基于对象、双下划线查询
    Django ORM
    Django 模板层
    Django视图层
    Django 路由控制
    Django完成常用四大功能
    Django 框架之前
    HTTP协议
    CSS-学习笔记五
  • 原文地址:https://www.cnblogs.com/wangyuebo/p/5826076.html
Copyright © 2011-2022 走看看