免费注册 查看新帖 |

Chinaunix

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

sed 学习笔记(与大家共勉)  关闭 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2003-10-24 11:00 |只看该作者

sed 学习笔记(与大家共勉)

太好了!
那个sed&awk.pdf的文档哪里能找到?
Greenergy 该用户已被删除
22 [报告]
发表于 2003-10-24 20:17 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
23 [报告]
发表于 2003-10-25 14:51 |只看该作者

sed 学习笔记(与大家共勉)

[quote]原帖由 "admirer"]参考资料:<sed&awk.pdf>等[/quote 发表:
     老大,对你的参考资料比较感兴趣

论坛徽章:
0
24 [报告]
发表于 2003-10-27 08:11 |只看该作者

sed 学习笔记(与大家共勉)

好文件已收藏!!

论坛徽章:
0
25 [报告]
发表于 2003-10-27 09:12 |只看该作者

sed 学习笔记(与大家共勉)

俺顶

论坛徽章:
0
26 [报告]
发表于 2003-10-27 09:26 |只看该作者

sed 学习笔记(与大家共勉)

支持

论坛徽章:
0
27 [报告]
发表于 2004-01-02 17:03 |只看该作者

sed 学习笔记(与大家共勉)

太牛乐
可惜看到4.3就看不动了  :(

论坛徽章:
0
28 [报告]
发表于 2004-04-27 21:30 |只看该作者

sed 学习笔记(与大家共勉)

我要加紧学习

论坛徽章:
0
29 [报告]
发表于 2005-03-13 17:30 |只看该作者

sed 学习笔记(与大家共勉)

sed -n -e '/test/{=;x;1!p;g;$!N;p;D;}' -e h  file

=lace the current line number on the standard output as a line.
x:Exchange the contents of the pattern and hold spaces.
print.  Copy the pattern space to the standard output.
g:Replace the contents of the pattern space by the contents of the hold space.
N:Append the next line of input to the pattern space with an embedded new-line.
  (The current line number changes.) If the end of input is reached, the N command verb shall branch to the end of the script
print.  Copy the pattern space to the standard output.
Delete the initial segment of the pattern space through the first new-line.Start the next cycle.  (See the N command below.)
h:Replace the contents of the hold space by the contents of the pattern space.
楼主能不能解释一下上面的命令,我就是没看出来sed是怎么存储匹配行的上面一行的?

论坛徽章:
0
30 [报告]
发表于 2005-03-16 11:39 |只看该作者

sed 学习笔记(与大家共勉)

echo "WeLoveChinaUnix"|sed -e 'H;s/\(..\).*/\1/;x;s/.*\(.\{9\}\)$/\1/;x;G;s/\n/ /'
-------------------------------------------------------------------------------
-e 可不用
H  建议为h
先取后9个,再取前2个可少一步最后的x

如果单纯为完成功能,可为:
echo "WeLoveChinaUnix"|sed  's/^\(..\).*\(.\{9\}\)$/\1 \2/'
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP