UNIX® Shells by Example, Third Edition笔记1

系统 1892 0
1. grep 's Regular Expression Metacharacters(Which I always dismissed~)
[^] Matches one character not in the set '[^A–K]ove' Matches lines not containing a character in the range A through K, followed by ove.
\< Beginning-of-word anchor '\<love' Matches lines containing a word that begins with love.
\> End-of-word anchor 'love\>' Matches lines containing a word that ends with love.
\(..\) Tags matched characters '\(love\)ing' Tags marked portion in a register to be remembered later as number 1. To reference later, use \ 1 to repeat the pattern. May use up to nine tags, starting with the first tag at the left-most part of the pattern. For example, the pattern love is saved in register 1 to be referenced later as \ 1.
x\{m\} x\{m,\} x\{m,n\} [a] Repetition of character x: m times, at least m times, or between m and n times 'o\{5\}' 'o\{5,\}' 'o\{5,10\}' Matches if line has 5 occurences of o , at least 5 occurences of o , or between 5 and 10 occurrences of o .


EXPLANATION

Prints the line if it contains the word north. The \< is the beginning-of-word anchor, and the \> is the end-of-word anchor.

4. grep 's Options

Option What It Does
–b Precedes each line by the block number on which it was found. This is sometimes useful in locating disk block numbers by context.
–c Displays a count of matching lines rather than displaying the lines that match.
–h Does not display filenames.
–i Ignores the case of letters in making comparisons (i.e., upper-- and lowercase are considered identical).
–l Lists only the names of files with matching lines (once), separated by newline characters.
–n Precedes each line by its relative line number in the file.
–s Works silently, that is, displays nothing except error messages. This is useful for checking the exit status.
–v Inverts the search to display only lines that do not match.
–w Searches for the expression as a word, as if surrounded by \< and \>. This applies to grep only. (Not all versions of grep support this feature; e.g., SCO UNIX does not.)



UNIX® Shells by Example, Third Edition笔记1


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论