2010年11月10日 星期三

如何找出.git目錄

開發android
要搜尋某個字串 在整個android內
想要跳過.git目錄不搜尋
藉此來降低搜尋上的時間

如何找出該目錄下的.git目錄了

find . -type d -name '\.git'

-type d 找目錄
-type f 找檔案

-name '\.git'
找尋.git目錄

感謝charles教學
要犧牲下班時間教學
尤其感動

所以我要把所有.git刪掉才可以下班

Update 20101112
Checko提供的指令完全正確

完全正確
真的是太神了
find . -type d -name '\.git' -print0 | xargs -0 rm -rf

find
-print0
True; print the full file name on the standard output, followed
by a null character (instead of the newline character that
-print uses). This allows file names that contain newlines or
other types of white space to be correctly interpreted by pro‐
grams that process the find output. This option corresponds to
the -0 option of xargs.

xargs - build and execute command lines from standard input

--null
-0 Input items are terminated by a null character instead of by
whitespace, and the quotes and backslash are not special (every
character is taken literally). Disables the end of file string,
which is treated like any other argument. Useful when input
items might contain white space, quote marks, or backslashes.
The GNU find -print0 option produces input suitable for this
mode.

透過Facebook分享

1 則留言:

checko 提到...

把所有find 找出來2刪掉:

find . -type d -name '\.git' -print0 | xargs -0 rm -rf

好像是這樣...