加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_马鞍山站长网 (https://www.0555zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

Sed - An Introduction and Tutorial by Bruce Barnett

发布时间:2021-01-29 10:07:16 所属栏目:站长百科 来源:网络整理
导读:副标题#e# http://www.grymoire.com/unix/sed.html Quick Links - NEW table border="1" tr Sed Pattern Flags /tr tr td a href="http://www.grymoire.com/unix/Sed.html#uh-6"gt;/g?- Global/td /tr tr td a href="http://www.grymoire.com/unix/Sed.html

It isn't obvious,but?sed?could be used instead of?tr. You can embed a new line in a substitute command,but you must escape it with a backslash. It is unfortunate that you must use "n" in the left side of a substitute command,and an embedded new line in the right hand side. Heavy sigh. Here is the example:

#!/bin/sh
sed '
s/ /
/' | 
sed ' {
    y/abcdef/ABCDEF/
    N
    s/n/ /
}'

Click here to get file:?

Sometimes I add a special character as a marker,and look for that character in the input stream. When found,it indicates the place a blank used to be. A backslash is a good character,except it must be escaped with a backslash,and makes the?sed?script obscure. Save it for that guy who keeps asking dumb questions. The?sedscript to change a blank into a "" following by a new line would be:?#!/bin/shsed 's/ //' file

Click here to get file:?

Yeah. That's the ticket. Or use the C shell and really confuse him!?#!/bin/csh -fsed 's/ /\/' file

Click here to get file:?

A few more examples of that,and he'll never ask you a question again! I think I'm getting carried away. I'll summarize with a chart that covers the features we've talked about:

Pattern Space (编辑:网站开发网_马鞍山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

Next Input Command Output New Pattern Space New Text Input