中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

服裝店網(wǎng)站模板網(wǎng)站快速建站

服裝店網(wǎng)站模板,網(wǎng)站快速建站,電腦城網(wǎng)站開發(fā)需求分析,石家莊網(wǎng)站制作報價一.grep簡介 grep 全程Globally search a Regular Expression and Print,是一種強大的文本搜索工具,它能使用特定模式匹配(包括正則表達式)搜索文本,并默認輸出匹配行。Unix的grep家族包括grep和egrep 二.grep的工作…

.grep簡介

grep 全程Globally search a Regular Expression and Print,是一種強大的文本搜索工具,它能使用特定模式匹配(包括正則表達式)搜索文本,并默認輸出匹配行。Unixgrep家族包括grepegrep

.grep的工作模式

2.1.grep執(zhí)行語法

grep [option] file...

2.2.工作方式

  • grep在一個或者多個文件中搜索字符串模板
  • 如果模板中包括空格,需要使用引號引起來

  • 模板后的所有字符串會被看作是文件名

2.3.工作結果

  • 如果模板搜索成功,則返回0狀態(tài)碼
  • 如果搜索不成功,則返回1狀態(tài)碼
  • 如果搜索的文件不存在,則返回2的狀態(tài)碼。

.grep的常用參數(shù)詳解

3.1.常用參數(shù)詳解

?3.2.演示示例

a)建立測試文件

[root@haha 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字符串的行

[root@haha 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:root
c )過濾包含 root 單詞的行
[root@haha 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:root
d )過濾含有 root 字符的行忽略大小寫
[root@haha 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:root
e )過濾含有 root 單詞和 bash 單詞的行
[root@haha 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:root
f )只顯示匹配內(nèi)容不不顯示其他并標注行號
[root@timinglee shell]# grep -on root testfile
1:root
1:root
1:root
10:root
11:root
13:root
14:root
g )顯示包含 root 字符串的行的總數(shù)
[root@haha shells]# grep -c root testfile 
5
h )顯示不含有 root 的行
[root@haha 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
[root@haha 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/sync
k)顯示含有 adm 關鍵字及其下面 1
[root@haha shells]# grep -A1 adm testfile 
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
l )顯示含有 adm 關鍵字及其上面 2
[root@haha 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 ),又稱為標準正則表達式,是最早制訂的正則表達式規(guī)范,僅支持最基本的元字符集?;菊齽t表達式是POSIX 規(guī)范制訂的兩種正則表達式語法標準之一,另外一種語法標準稱為擴展正則表達式
擴展正則表達式( Extended Regular Expression ERE )支持比基本正則表達式更多的元字符

?

在grep命令使用基本正則表達式時不需要加任何參數(shù)

在grep命令使用擴展正則表達式時必須加-E參數(shù)

示例:

a )過濾以 root 開頭的行,過濾以 root 開頭 bash 結尾的行
[root@haha shells]# grep ^root testfile 
root:x:0:0:root:/root:/bin/bash
[root@haha shells]# grep -E "(^root|bash$)" testfile 
root:x:0:0:root:/root:/bin/bash
[root@haha shells]# 
b )過濾以 root 結尾的行
[root@haha shells]# grep root$ testfile 
test:test:root
c )搜索 e 開頭 y 結尾的三字符單詞,搜索 e 開頭 y 結尾的四字符單詞
[root@haha shells]# grep e.y testfile1
eay
eby
[root@haha shells]# grep e..y testfile1
eaay
ebby
eaby
d )搜索 e 開頭 Y 結尾的所有行
[root@haha shells]# grep e.*y testfile1
eay
eby
eaay
ebby
eaaay
ebbby
eaaaaay
ebbbbby
eababy
eaby
eabababy
e)搜索自定次數(shù)出現(xiàn)的字符
[root@haha shells]# grep -E "e.{2}y" testfile1
eaay
ebby
eaby
[root@haha shells]# grep -E "e.{,2}y" testfile1
eay
eby
eaay
ebby
eaby
[root@haha shells]# grep -E "e.{2,}y" testfile1
eaay
ebby
eaaay
ebbby
eaaaaay
ebbbbby
eababy
eaby
eabababy
[root@haha shells]# grep -E "e.+y" testfile1
eay
eby
eaay
ebby
eaaay
ebbby
eaaaaay
ebbbbby
eababy
eaby
eabababy
[root@haha shells]# grep -E "e.?y" testfile1
eay
eby
[root@haha shells]# grep -E "e[ab]y" testfile1
eay
eby
[root@haha shells]# grep -E "e[^ac]y" testfile1
eby
[root@haha shells]# grep -E "e(ab)+y" testfile1
eababy
eaby
eabababy
[root@haha shells]# grep -E "e(ab)?y" testfile1
eaby

4.3.正則表達式字符集

示例:

[root@haha 1]# touch easyalee easyAlee "easy lee" "easy@lee" "easy8lee"
[root@haha 1]# rm -rf easy[[:digit:]]lee
[root@haha 1]# rm -rf easy[[:space:]]lee
[root@haha 1]# rm -rf easy[[:lower:]]lee
[root@haha 1]# rm -rf easy[[:upper:]]lee
[root@haha 1]# rm -rf easy[[:graph:]]lee
[root@haha 1]# rm -rf easy[[:alpha:]]lee
http://www.risenshineclean.com/news/28017.html

相關文章:

  • 深圳龍崗網(wǎng)站維護阿里域名購買網(wǎng)站
  • 兩個人能用的一個公司做網(wǎng)站嗎怎樣注冊網(wǎng)站免費注冊
  • 貴陽網(wǎng)站建設制作成都最新消息今天
  • 做網(wǎng)站公司在深圳谷歌瀏覽器官方app下載
  • 安徽建設行業(yè)安全協(xié)會網(wǎng)站友情鏈接交易平臺
  • 社區(qū)電商網(wǎng)站設計磁力搜索引擎
  • 寧波公司網(wǎng)站開發(fā)推廣營銷是什么
  • 為什么做視頻網(wǎng)站違法礦產(chǎn)網(wǎng)站建設價格
  • 阿里云wordpress很慢找seo外包公司需要注意什么
  • 心雨在線高端網(wǎng)站建設關鍵詞分析軟件
  • 成都官方網(wǎng)站建設seo怎么做關鍵詞排名
  • 建立淘寶客網(wǎng)站福州短視頻seo網(wǎng)紅
  • 做外貿(mào)的網(wǎng)站怎么建立武漢seo網(wǎng)站排名優(yōu)化
  • 做理財?shù)木W(wǎng)站有哪些搜索引擎推廣方案
  • 網(wǎng)站建設多久可以建成seo是搜索引擎優(yōu)化
  • 四字母net做網(wǎng)站怎么樣競價推廣和信息流推廣
  • 比較大氣的網(wǎng)站深圳短視頻推廣
  • 邵陽網(wǎng)站建設推廣域名權重
  • 視頻網(wǎng)站的服務器建設百度熱搜榜小說排名
  • 委托網(wǎng)站建設注意什么個人如何推廣app
  • asp.net視頻網(wǎng)站模板下載站長網(wǎng)站工具
  • 產(chǎn)品宣傳類網(wǎng)站設計互聯(lián)網(wǎng)推廣公司靠譜嗎
  • php網(wǎng)站開發(fā)套模板步驟打開百度首頁
  • 查詢企業(yè)聯(lián)系方式的軟件亞馬遜排名seo
  • 影城網(wǎng)站建設濟南優(yōu)化網(wǎng)站關鍵詞
  • 臨安做企業(yè)網(wǎng)站搜索引擎營銷的方法
  • 湖北省網(wǎng)站建設杭州網(wǎng)站推廣優(yōu)化公司
  • 廣東住房和建設局網(wǎng)站百度付費推廣有幾種方式
  • 互聯(lián)科技 行業(yè)網(wǎng)站軟文廣告是什么
  • wordpress必須登錄北京網(wǎng)站優(yōu)化seo