zoukankan      html  css  js  c++  java
  • learn Linux sed command

                                      learn Linux sed command
    
    
    一、参考文档:
        1. sed命令详解
            http://qifuguang.me/2015/09/21/sed%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/
        2. linux之sed用法
            http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html
        3. Sed 的man手册参数详细解释(一)
            http://blog.csdn.net/imfinger/article/details/6071175
    
    二、sed命令的使用规则是这样的:
        sed [option] 'command' input_file
    
    三、options:
        -n, --quiet, --silent
            suppress automatic printing of pattern space
        -e script, --expression=script
            add the script to the commands to be executed
            如果命令行上只有一个指令的时候可以不用写-e,但是如果有多个指令的话一定要在每个指令的前面加-e选项。
        -f script-file, --file=script-file
            add the contents of script-file to the commands to be executed
            这里貌似是前面对应的-e对应的脚本
        --follow-symlinks
            follow symlinks when processing in place
        -i[SUFFIX], --in-place[=SUFFIX]
            edit files in place (makes backup if extension supplied)
        -l N, --line-length=N
            specify the desired line-wrap length for the `l' command
        --posix
            disable all GNU extensions.
        -r, --regexp-extended
            use extended regular expressions in the script.
        -s, --separate
            consider  files  as  separate rather than as a single continuous
            long stream.
        -u, --unbuffered
            load minimal amounts of data from the input files and flush  the
            output buffers more often
        --help
            display this help and exit
        --version
            output version information and exit
    
    四、command有以下几种:
        a : append即追加字符串, a 的后面跟上字符串s(多行字符串可以用
    分隔),则会在当前选择的行的后面都加上字符串s;
        c : 取代/替换字符串,c 后面跟上字符串s(多行字符串可以用
    分隔),则会将当前选中的行替换成字符串s;
        d  : delete即删除,该命令会将当前选中的行删除;
        i : insert即插入字符串,i 后面跟上字符串s(多行字符串可以用
    分隔),则会在当前选中的行的前面都插入字符串s;
        p  : print即打印,该命令会打印当前选择的行到屏幕上;
        s  : 替换,通常s命令的用法是这样的:1,2s/old/new/g,将old字符串替换成new字符串
  • 相关阅读:
    【视频剪辑】 Land of Dreams 航拍中国新疆篇 剪辑
    【视频剪辑】 2018年中国海空军掠影
    【视频剪辑】 成都雅安旅行vlog
    【PL/SQL】 学习笔记 (3)if 语句使用
    【PL/SQL】 学习笔记 (2)引用型变量和记录型变量
    dubbo远程方法调用的基本原理
    java8中的接口与时间操作
    接入天猫精灵auth2授权页面https发送ajax请求
    java8 流操作
    Lambda表达式和方法引用
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/4970745.html
Copyright © 2011-2022 走看看