• sed did you learning it ?


    shark@shark:~$ sed --help
    Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
    
      -n, --quiet, --silent
                     suppress automatic printing of pattern space
          --debug
                     annotate program execution
      -e script, --expression=script
                     add the script to the commands to be executed
      -f script-file, --file=script-file
                     add the contents of script-file to the commands to be executed
      --follow-symlinks
                     follow symlinks when processing in place
      -i[SUFFIX], --in-place[=SUFFIX]
                     edit files in place (makes backup if SUFFIX supplied)
      -l N, --line-length=N
                     specify the desired line-wrap length for the `l' command
      --posix
                     disable all GNU extensions.
      -E, -r, --regexp-extended
                     use extended regular expressions in the script
                     (for portability use POSIX -E).
      -s, --separate
                     consider files as separate rather than as a single,
                     continuous long stream.
          --sandbox
                     operate in sandbox mode (disable e/r/w commands).
      -u, --unbuffered
                     load minimal amounts of data from the input files and flush
                     the output buffers more often
      -z, --null-data
                     separate lines by NUL characters
          --help     display this help and exit
          --version  output version information and exit
    
    If no -e, --expression, -f, or --file option is given, then the first
    non-option argument is taken as the sed script to interpret.  All
    remaining arguments are names of input files; if no input files are
    specified, then the standard input is read.
    
    GNU sed home page: <https://www.gnu.org/software/sed/>.
    General help using GNU software: <https://www.gnu.org/gethelp/>.
    E-mail bug reports to: <bug-sed@gnu.org>.
    shark@shark:~$                                            
    
    

    sed命令行格式为:
    sed [-nefri] ‘command’ 输入文本
    常用选项:
    -n∶使用安静(silent)模式。在一般 sed 的用法中,所有来自 STDIN的资料一般都会被列出到萤幕上。但如果加上 -n 参数后,则只有经过sed 特殊处理的那一行(或者动作)才会被列出来。
    -e∶直接在指令列模式上进行 sed 的动作编辑;
    -f∶直接将 sed 的动作写在一个档案内, -f filename 则可以执行 filename 内的sed 动作;
    -r∶sed 的动作支援的是延伸型正规表示法的语法。(预设是基础正规表示法语法)
    -i∶直接修改读取的档案内容,而不是由萤幕输出。

    常用命令:
    a ∶新增, a 的后面可以接字串,而这些字串会在新的一行出现(目前的下一行)~
    c ∶取代, c 的后面可以接字串,这些字串可以取代 n1,n2 之间的行!
    d ∶删除,因为是删除啊,所以 d 后面通常不接任何咚咚;
    i ∶插入, i 的后面可以接字串,而这些字串会在新的一行出现(目前的上一行);
    p ∶列印,亦即将某个选择的资料印出。通常 p 会与参数 sed -n 一起运作~
    s ∶取代,可以直接进行取代的工作哩!通常这个 s 的动作可以搭配正规表示法!例如 1,20s/old/new/g!

         g 是行内进行全局替换
  • 相关阅读:
    hive.exec.parallel参数
    MySQL FEDERATED 提示
    mapreduce作业单元测试
    linux 更改mysql的数据库目录
    SQL Server 2008数据库邮件配置及应用
    mysql主键大小写不敏感的解决办法
    java遍历hashMap、hashSet、Hashtable
    Linux下命令行显示当前全路径方法
    通过SQL Server操作MySQL的步骤和方法
    Linux shell获取时间和时间间隔(ms级别)
  • 原文地址:https://www.cnblogs.com/qianxiaoruofeng/p/13863014.html
Copyright © 2020-2023  润新知