小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

grep 搜索目錄時,怎樣排除某些目錄?

 灬木木的花灬 2015-09-15

使用 grep 搜索目錄時,會將一些隱藏目錄也給搜進去,比如 .git 目錄。如何在使用 grep 時排除這些目錄呢?


    使用 --exclude-dir 選項。

語法

--exclude-dir=DIR
Exclude directories matching the pattern DIR from recursive searches.

單個目錄示例

grep -E "http"  ./ -R --exclude-dir=.git 

多個目錄示例

grep -E "http"  . -R --exclude-dir={.git,res,bin}

多個文件示例

附贈一個,排除擴展名為 java 和 js 的文件

grep -E "http"  . -R --exclude=*.{java,js}
0
秦書磊 129 2014年12月08日 回答

grep太羅嗦,用ack吧。源碼搜索的不二之選~默認排除各種版本庫,可以指定多種源文件類型。

─(~/.cheat)(ruby-1.9.3-p547@rails3.1.1)────────────────────────────────────────────────────────────────────(shuleiqin@shuleiqin-F8Vr:pts/0)─┐
└─(23:14:07 on master)──> ls                                                                                                  ──(一,12月08)─┘
alias  bash  crontab  DirectoryArchitecture  echo    Git   kill  MachineProperties  passwd  Python     Regex     tree     usermod  Vi
awk    Bash  df       du                     export  grep  less  markdown           python  README.md  shutdown  useradd  vi       zip
┌─(~/.cheat)(ruby-1.9.3-p547@rails3.1.1)────────────────────────────────────────────────────────────────────(shuleiqin@shuleiqin-F8Vr:pts/0)─┐
└─(23:14:16 on master)──> ack grep                                                                                             ──(一,12月08)─┘

grep
2:grep pattern file
5:grep -i pattern file
7:# Recursively grep for string <pattern> in folder:
8:grep -R pattern folder
11:grep -Rl {search} {path}
14:grep -Rli {search} {path}
17:grep -f pattern_file file
20:grep -v pattern file
22:# You can grep with regular expressions
23:grep "^00" file  #Match lines starting with 00
24:grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file  #Find IP add
28:grep -rnw 'directory' -e "pattern"
30:# Exclude grep from your grepped output of ps.
32:ps aux | grep '[h]ttpd'
35:ps aux | grep -E --color 'bash

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多