免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: kangtadj
打印 上一主题 下一主题

sed 多行替换问题 [复制链接]

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
11 [报告]
发表于 2012-04-19 20:50 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
12 [报告]
发表于 2012-04-19 22:53 |只看该作者
集合,哈 8楼,攒

论坛徽章:
0
13 [报告]
发表于 2012-04-20 09:33 |只看该作者
8楼 牛逼
dragon23452345 该用户已被删除
14 [报告]
发表于 2012-04-20 10:33 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
15 [报告]
发表于 2012-04-20 10:54 |只看该作者
回复 14# dragon23452345


   
3.5.1 Brace Expansion

Brace expansion is a mechanism by which arbitrary strings may be generated. This mechanism is similar to filename expansion (see Filename Expansion), but the file names generated need not exist. Patterns to be brace expanded take the form of an optional preamble, followed by either a series of comma-separated strings or a seqeunce expression between a pair of braces, followed by an optional postscript. The preamble is prefixed to each string contained within the braces, and the postscript is then appended to each resulting string, expanding left to right.

Brace expansions may be nested. The results of each expanded string are not sorted; left to right order is preserved. For example,

     bash$ echo a{d,c,b}e
     ade ace abe

http://www.gnu.org/software/bash/manual/bash.html#Brace-Expansion

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
16 [报告]
发表于 2012-04-20 10:58 |只看该作者
sed '1ba;3ba;7ba;8ba;d;:a;........

论坛徽章:
0
17 [报告]
发表于 2012-04-20 15:21 |只看该作者
这个不支持单行啊

sed -e{7}'s/PP-GO/PP-GO1/' /etc/hosts

论坛徽章:
0
18 [报告]
发表于 2012-04-20 15:26 |只看该作者
回复 17# kangtadj


    {,7}

论坛徽章:
0
19 [报告]
发表于 2012-04-20 15:29 |只看该作者
不对吧
文件内容:
  PP-GO localhost localhost
# Internet host table
#
::1             localhost
127.0.0.1       localhost
111             111     333
10.167.157.114  PP-GO   # Added by DHCP

-----------------------------------------------

sed -e{,7}'s/PP-GO/PP-GO1/' /etc/hosts

  PP-GO1 localhost localhost
# Internet host table
#
::1             localhost
127.0.0.1       localhost
111             111     333
10.167.157.114  PP-GO11 # Added by DHCP


明显错了啊

论坛徽章:
0
20 [报告]
发表于 2012-04-20 16:25 |只看该作者
本帖最后由 hbmhalley 于 2012-04-20 16:25 编辑

回复 19# kangtadj


    不好意思想错了。
    不过 “followed by either a series of comma-separated strings or a seqeunce expression between a pair of braces”
    必须有逗号或..才算 brace expansion

    必须要统一格式么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP