个人工具
登录
查看“UbuntuHelp:Grep”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:Grep”的源代码
来自Ubuntu中文
←
UbuntuHelp:Grep
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/grep}} {{Languages|UbuntuHelp:grep}} == What Is grep? == '''Grep''' is a command line tool that allows you to find a string in a file or stream. It can be used with Regular expression to be more flexible at finding strings. === How To Use grep === In the simplest case, grep can simply be invoked like this : <pre><nowiki> % grep 'STRING' filename </nowiki></pre> This is OK but it does not show the true power of grep. First this only looks at one file. A cool example of using grep with multiple file would be to find all files in a directory that contains the name of a person. This can be easily accomplished using a grep in the following way : <pre><nowiki> % grep 'Nicolas Kassis' * </nowiki></pre> Notice the use of single quotes; This are not essential but in this example it was required since the name contains a space. Double quotes could also have been used in this example. Now lets use some regular expressions... === Grep Regular Expression === grep can search for complicated pattern to find what you need. Here is a list of some of the special characters used to create a regular expression: {|border="1" cellspacing="0" |||||'''Grep Regular Expression''' |- | ^ || Denotes the beginning of a line |- | $ || Denotes the end of a line |- | . || Matches any one characters |- | * || Matches 0 or more of the previous characters |- | .* || Matches any number or type of characters |- | [] || Matches on character for the one listed in the the Square brackets |- | [^] || Does not match any characters listed |- | \<, >/ || Denotes the beginning and end (respectively) of a word |} So an example of a regular expression search would be <pre><nowiki> % grep "\<[A-Za-z].*" file </nowiki></pre> This will search for any word which begins with a letter upper or lower case. For more details check: * [[UbuntuHelp:BasicCommands|BasicCommands]] * http://www.gnu.org/software/grep/doc/ * http://en.wikipedia.org/wiki/Grep * '''man grep''' and '''info grep''' on your computer ---- [[category:CategoryDocumentation]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:Grep
。