⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e6

📁 unix v7是最后一个广泛发布的研究型UNIX版本
💻
字号:
.SHSpecial Characters.PPYou may have noticed that things just don't work right when you usedsome characters like\*.,.UL * ,.UL $ ,and others incontext searches and the substitute command.The reason is rather complex, although the cure is simple.Basically,.uledtreats these characters as special, with special meanings.For instance,.ulin a context search or the first string of the substitute command only,\*.means ``any character,'' not a period, so.P1/x\*.y/.P2means ``a line with an.UL x ,.ulany character,and a.UL y ,''.ulnotjust ``a line with an.UL x ,a period, and a.UL y .''A complete list of the special charactersthat can cause trouble is the following:.P1^    \*.    $    [    *    \e.P2.ulWarning:The backslash character.UL \eis special to.uled.For safety's sake, avoid it where possible.If you have to use one of the special charactersin a substitute command,you can turn off its magic meaning temporarilyby preceding it with the backslash.Thus.P1s/\e\e\e\*.\e*/backslash dot star/.P2will change.UL \e.*into ``backslash dot star''..PPHere is a hurried synopsis of the other special characters.First, the circumflex.UL ^signifiesthe beginning of a line.Thus.P1/^string/.P2finds.UL stringonly if it is at the beginning of a line:it will find.P1string.P2but not.P1the string....P2The dollar-sign.UL $is just the opposite of the circumflex;it means the end of a line:.P1/string$/.P2will only find an occurrence of.UL stringthat is at the end of some line.This implies, of course,that.P1/^string$/.P2will find only a line that contains just.UL string ,and.P1/^\*.$/.P2finds a line containing exactly one character..PPThe character.UL . ,as we mentioned above,matches anything;.P1/x\*.y/.P2matches any of.P1x+yx-yx yx\*.y.P2This is useful in conjunction with.UL * ,which is a repetition character;.UL a*is a shorthand for ``any number of.UL a 's,''so .UL .*matches any number of anythings.This is used like this:.P1s/\*.*/stuff/.P2which changes an entire line,or.P1s/\*.*,//.P2which deletes all characters in the line up to andincluding the last comma.(Since.UL .*finds the longest possible match,this goes up to the last comma.).PP.UL [is used with.UL ]to form ``character classes'';for example,.P1/[0123456789]/.P2matches any single digit \-any one of the characters inside the braceswill cause a match.This can be abbreviated to.UL [0\-9] ..PPFinally, the.UL &is another shorthand character \-it is used only on the right-hand part of a substitute commandwhere it means ``whatever was matched on the left-hand side''.It is used to save typing.Suppose the current line contained.P1Now is the time.P2and you wanted to put parentheses around it.You could just retype the line, butthis is tedious.Or you could say.P1s/^/(/s/$/)/.P2using your knowledge of.UL ^and.UL $ .But the easiest way uses the.UL & :.P1s/\*.*/(&)/.P2This says ``match the whole line, and replace itby itself surrounded by parentheses.''The.UL &can be used several times in a line;considerusing.P1s/\*.*/&?  &!!/.P2to produce.P1Now is the time?  Now is the time!!.P2.PPYou don't have to match the whole line, of course:if the buffer contains.P1the end of the world.P2you could type.P1/world/s//& is at hand/.P2to produce.P1the end of the world is at hand.P2Observe this expression carefully,for it illustrates how to take advantage of.uledto save typing.The string.UL /world/found the desired line;the shorthand.UL //found the sameword in the line;and the.UL &saves you from typing it again..PPThe.UL &is a special character only withinthe replacement text of a substitute command,and has no special meaning elsewhere.You can turn off the special meaning of.UL &by preceding it with a.UL \e :.P1s/ampersand/\e&/.P2will convert the word ``ampersand'' into the literal symbol.UL &in the current line.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -