• 50个常用的Linux命令(二)sed


    [root@localhost cee]# echo this thisthisthis |sed 's/this/THIS/g'
    THIS THISTHISTHIS
    [root@localhost cee]# echo this thisthisthis |sed 's/this/THIS/2g'
    this THISTHISTHIS
    [root@localhost cee]# echo this thisthisthis |sed 's/this/THIS/3g'
    this thisTHISTHIS
    [root@localhost cee]# echo this thisthisthis |sed 's/this/THIS/4g'
    this thisthisTHIS


    [root@localhost cee]# cat temp
    i love linux

    i love python
    william
    [root@localhost cee]# sed '/^$/d' temp
    i love linux
    i love python
    william
    [root@localhost cee]# cat temp
    i love linux

    i love python
    william

    [root@localhost cee]# echo this is an example |sed 's/w+/[&]/g'
    [this] [is] [an] [example]
    [root@localhost cee]# echo this is an example |sed 's/w+/"&"/g'
    "this" "is" "an" "example"
    [root@localhost cee]# echo this is digit 7 in a number | sed 's/digit ([0-9])/1/g'
    this is 7 in a number

    [root@localhost cee]# echo seven EIGHT |sed 's/([a-z]+) ([A-Z]+)/2 1/g'
    EIGHT seven

    sed 'exp'|sed 'exp2' == sed 'exp;exp2'

    [root@localhost cee]# text=hello
    [root@localhost cee]# echo hello world | sed "s/$text/HELLO/g"
    HELLO world

  • 相关阅读:
    Python数据类型之数值-Python基础前传(5)
    R语言之数据可视化
    R语言之数据可视化
    R语言基础
    R语言基础
    R语言基础
    R语言入门
    R语言入门
    用 python 爬取 gutenberg 上的英文科幻小说
    Python 在数据科学中的应用
  • 原文地址:https://www.cnblogs.com/william126/p/10396265.html
Copyright © 2020-2023  润新知