当前位置: 首页 > news >正文

网站内部链接手表东莞网站建设技术支持

网站内部链接,手表东莞网站建设技术支持,百度竞价渠道代理商,网站建设西安一.grep简介 grep 全程Globally search a Regular Expression and Print#xff0c;是一种强大的文本搜索工具#xff0c;它能使用特定模式匹配#xff08;包括正则表达式#xff09;搜索文本#xff0c;并默认输出匹配行。Unix的grep家族包括grep和egrep 二.grep的工作…一.grep简介 grep 全程Globally search a Regular Expression and Print是一种强大的文本搜索工具它能使用特定模式匹配包括正则表达式搜索文本并默认输出匹配行。Unix的grep家族包括grep和egrep 二.grep的工作模式 2.1.grep执行语法 grep [option] file... 2.2.工作方式 grep在一个或者多个文件中搜索字符串模板 如果模板中包括空格需要使用引号引起来 模板后的所有字符串会被看作是文件名 2.3.工作结果 如果模板搜索成功则返回0状态码 如果搜索不成功则返回1状态码 如果搜索的文件不存在则返回2的状态码。 三.grep的常用参数详解 3.1.常用参数详解 3.2.演示示例 a建立测试文件 [roothaha shells]# vim testfile root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin test:root:test test:ROOT:test test:chroot:test test:test:root b过滤文件中所有含有root字符串的行 [roothaha shells]# grep root testfile root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin test:root:test test:chroot:test test:test:rootc 过滤包含 root 单词的行 [roothaha shells]# grep root testfile -w root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin test:root:test test:test:rootd 过滤含有 root 字符的行忽略大小写 [roothaha shells]# grep root testfile -i root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin test:root:test test:ROOT:test test:chroot:test test:test:roote 过滤含有 root 单词和 bash 单词的行 [roothaha shells]# grep -w -e root -e bash testfile root:x:0:0:root:/root:/bin/bash operator:x:11:0:operator:/root:/sbin/nologin test:root:test test:test:rootf 只显示匹配内容不不显示其他并标注行号 [roottiminglee shell]# grep -on root testfile 1:root 1:root 1:root 10:root 11:root 13:root 14:root g 显示包含 root 字符串的行的总数 [roothaha shells]# grep -c root testfile 5h 显示不含有 root 的行 [roothaha shells]# grep -v root testfile bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin j 显示含有 adm 关键字及其周围的 2 行 [roothaha shells]# grep -2 adm testfile bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/synck显示含有 adm 关键字及其下面 1 行 [roothaha shells]# grep -A1 adm testfile adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologinl 显示含有 adm 关键字及其上面 2 行 [roothaha shells]# grep -B2 adm testfile bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin四.正则表达式的使用 4.1.什么是正则表达式 正则表达式就是用在字符串的处理上面的一项表示式 在我们做程序设计时很多需要对一类字符进行处理正则表达式就完美的解决了这个问题 4.2.正则表达式  基本正则表达式 Basic Regular Expression BRE 又称为标准正则表达式是最早制订的正则表达式规范仅支持最基本的元字符集。基本正则表达式是POSIX 规范制订的两种正则表达式语法标准之一另外一种语法标准称为扩展正则表达式 扩展正则表达式 Extended Regular Expression ERE 支持比基本正则表达式更多的元字符 在grep命令使用基本正则表达式时不需要加任何参数 在grep命令使用扩展正则表达式时必须加-E参数 示例 a 过滤以 root 开头的行过滤以 root 开头 bash 结尾的行 [roothaha shells]# grep ^root testfile root:x:0:0:root:/root:/bin/bash [roothaha shells]# grep -E (^root|bash$) testfile root:x:0:0:root:/root:/bin/bash [roothaha shells]# b 过滤以 root 结尾的行 [roothaha shells]# grep root$ testfile test:test:rootc 搜索 e 开头 y 结尾的三字符单词搜索 e 开头 y 结尾的四字符单词 [roothaha shells]# grep e.y testfile1 eay eby [roothaha shells]# grep e..y testfile1 eaay ebby eabyd 搜索 e 开头 Y 结尾的所有行 [roothaha shells]# grep e.*y testfile1 eay eby eaay ebby eaaay ebbby eaaaaay ebbbbby eababy eaby eabababye搜索自定次数出现的字符 [roothaha shells]# grep -E e.{2}y testfile1 eaay ebby eaby [roothaha shells]# grep -E e.{,2}y testfile1 eay eby eaay ebby eaby [roothaha shells]# grep -E e.{2,}y testfile1 eaay ebby eaaay ebbby eaaaaay ebbbbby eababy eaby eabababy [roothaha shells]# grep -E e.y testfile1 eay eby eaay ebby eaaay ebbby eaaaaay ebbbbby eababy eaby eabababy [roothaha shells]# grep -E e.?y testfile1 eay eby [roothaha shells]# grep -E e[ab]y testfile1 eay eby [roothaha shells]# grep -E e[^ac]y testfile1 eby [roothaha shells]# grep -E e(ab)y testfile1 eababy eaby eabababy [roothaha shells]# grep -E e(ab)?y testfile1 eaby4.3.正则表达式字符集 示例 [roothaha 1]# touch easyalee easyAlee easy lee easylee easy8lee [roothaha 1]# rm -rf easy[[:digit:]]lee [roothaha 1]# rm -rf easy[[:space:]]lee [roothaha 1]# rm -rf easy[[:lower:]]lee [roothaha 1]# rm -rf easy[[:upper:]]lee [roothaha 1]# rm -rf easy[[:graph:]]lee [roothaha 1]# rm -rf easy[[:alpha:]]lee
http://www.hkea.cn/news/14317794/

相关文章:

  • 华升建设集团公司网站wordpress apk
  • 2016建设银行辽宁招聘网站温州网站建设首选国鼎网络
  • 做照片相册最好的网站外贸自建站如何收款
  • 怎么做菠菜网站西安网络公司做网站
  • 网站怎样改logo电子商务网站建设组织流程图
  • 快速搭建网站软件网站建设规划图
  • 我的世界服务器赞助网站怎么做德州做网站公司电话
  • 微信怎么做网站推广东莞规划局
  • 麦味旅行的网站建设需求分析网站汇总表怎么做
  • 安宁网站建设与制作做网站的赚钱吗
  • 网站建设属于技术服务吗哪些网站可以做免费广告推广
  • 高端网站设计思路长沙微网站建设公司
  • 电子商务网站设计的基本要求茂名营销型网站制作公司
  • 有谁做彩票网站吗wordpress建站社区
  • 上海家装公司排名网站seo视频
  • 会议网站建设方案模板泰兴市建设局网站
  • 网站导航栏 字体济南网站建设的公司
  • 可信网站收费吗做网站需要知道什么软件
  • 上海网站建设公微信小程序如何推广
  • 可以免费搭建网站吗网站建站 seo
  • 佳木斯网站建设哪家好深圳做微信网站公司
  • 公司网站首页大图怎么做毕业网站设计
  • 网站正在建设中视频百色高端网站建设
  • 祥云县住房和城乡建设局网站江苏城乡住房和城乡建设厅网站
  • 长沙高端网站开发做详情页的网站
  • 郑州做企业网站哪家好wordpress能干什么
  • 东莞做网站网站免费建站人生若只初相见04
  • app与移动网站开发考试资料wordpress链接跳转错误
  • 网站 抄袭wordpress在php下安装教程
  • 江苏省宿迁市建设局网站邢台手机网站建设费用