zoukankan      html  css  js  c++  java
  • 学习总记录两个我觉得有意思的命令cat新建简单文件,sed任意特定行插入。

    cat 一般用来查看里面的文件内容。

    今天我想说的是

    [root@instance-erv5z0qp tmp]# cat > testfile << "over"
    > This is my test
    > hello ,my english very pool
    > bye bye
    > over
    [root@instance-erv5z0qp tmp]# cat testfile
    This is my test
    hello ,my english very pool
    bye bye

    后面的单词是结束语句提示词,这样新建一个简单的编辑好的文件感觉非常方便,不需要用vim新建保存什么的。

    还有一个sed,sed可以配合正则对一些输出进行删除,替换,

    我主要说的是插入

    [root@instance-erv5z0qp tmp]# cat testfile
    This is my test
    hello ,my english very pool
    bye bye
    [root@instance-erv5z0qp tmp]# sed -i '$a This is insert last' testfile
    [root@instance-erv5z0qp tmp]# cat testfile
    This is my test
    hello ,my english very pool
    bye bye
    This is insert last
    [root@instance-erv5z0qp tmp]# sed -i '2a second insert test' testfile
    [root@instance-erv5z0qp tmp]# cat testfile
    This is my test
    hello ,my english very pool
    second insert test
    bye bye
    This is insert last
    通过sed可以非常方便的在任意一行插入字段,第一个红色标注的$a表示最后插入

    第二个红色标注2a为第二行后面插入,a为插入的参数。

  • 相关阅读:
    vnc安装
    centos下安装图形界面
    granfana telegraf influx安装与使用
    jenkins安装与使用
    yum使用手册
    Python模块--并发相关threading、multiprocessing、Queue、gevent
    Python模块--logging
    Python模块--psutil
    python模块--Beautifulsoup
    Python模块--Pexpect
  • 原文地址:https://www.cnblogs.com/sidianok/p/11692938.html
Copyright © 2011-2022 走看看