|
Á¦ ¸ñ : find¸í·É¿¡¼ ƯÁ¤ µð·ºÅ丮 Á¦¿ÜÇÏ°í ã±â(exclude)
ÀÛ¼ºÀÚ : ÁÁÀºÁøÈ£(truefeel, http://coffeenix.net/ )
ÀÛ¼ºÀÏ : 2009.7.3(±Ý)
find ¸í·ÉÀ» ÇÒ ¶§, ƯÁ¤ µð·ºÅ丮 Á¦¿ÜÇÏ°í findÇÏ´Â ¹æ¹ýÀº ¾ø´À³Ä°í ÁÖÀ§ºÐÀÌ ¹°¾î¿À¼Ì´Ù.
°³ÀÎÀûÀ¸·Î´Â find¿¡¼ ƯÁ¤ µð·ºÅ丮¸¦ excludeÇÏ´Â °Í ´ë½Å¿¡ µð·ºÅ丮¸¦ ³ª¿ÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇß´Ù. ±×·¯³ª µð·ºÅ丮 °¹¼ö°¡ ¸¹°í, °°Àº depthÀÇ µð·ºÅ丮°¡ ¾Æ´Ï°í ÇÏÀ§ ƯÁ¤ µð·ºÅ丮 ¸î°³¸¦ excludeÇؾßÇÑ´Ù¸é? ¿É¼ÇÀ» È°¿ëÇÒ ¼ö ¹Û¿¡ ¾øÀ» °ÍÀÌ´Ù.
manÆäÀÌÁö¸¦ È®ÀÎÇغ¸´Ï -prune¿É¼ÇÀÌ ÀÖ´Ù. -prune ¿É¼ÇÀº ã¾Æ³½ °ÍÀÌ µð·ºÅ丮ÀÌ¸é ±× µð·ºÅ丮³»¿¡´Â findÇÏÁö ¾Ê´Â´Ù.
|
-name pattern
... »ý·« ...
To ignore a directory and the files under it, use -prune; see an example in the description of -wholename.
-prune If -depth is not given, true; if the file is a directory, do not descend into it.
If -depth is given, false; no effect.
| |
1. ¿¹Á¦·Î »ìÆ캸±â
[¿¹Á¦ 1] 2009°¡ Æ÷ÇÔµÈ ÆÄÀÏÀ» ã´Â´Ù. ´Ü ÆÄÀϸíÀÌ µð·ºÅ丮¿¡ ÇØ´çµÇ¸é ÇØ´ç µð·ºÅ丮 ÀÌÇϴ ãÁö ¾Ê´Â´Ù.
$ find (Àüü º¸±â)
./
./check/check_list_2008_12.php
./check/check_list_2009_05.php
./check/check_list_2009_06.php
./2007_10_mobile
./2008_01_highlight
./2008_01_highlight/view.pl
./2008_01_highlight/view.sh
./2009_03_MSIE8
./2009_03_MSIE8/get_MSIE8.sh
./2009_05_apache
./2009_05_game
./2009_05_game/2009_05.log
$ find . -name "*2009*" -prune
./check/check_list_2009_05.php
./check/check_list_2009_06.php
./2009_03_MSIE8
./2009_05_apache
./2009_05_game
./2009_05_game/ µð·ºÅ丮 ÀÌÇÏ¿¡ 2009_05.log ÆÄÀÏÀÌ ÀÖÁö¸¸, -prune¿É¼ÇÀ¸·Î ÇØ´ç µð·ºÅ丮 ÀÌÇϴ ãÁö ¾Ê¾Ò´Ù.
[¿¹Á¦ 2] ./foo/bar µð·ºÅ丮´Â Á¦¿ÜÇÏ°í, *.txt ÆÄÀÏÀ» ã¾Æ¶ó.
$ find . ! \( -path './foo/bar' -prune \) -name "*.txt"
$ find . ! \( -type d -path './foo/bar' -prune \) -name "*.txt" (º¸´Ù Á¤È®ÇÑ Ç¥Çö)
[¿¹Á¦ 3] ./foo/bar µð·ºÅ丮¿Í ./coffeenix/temp µð·ºÅ丮´Â Á¦¿ÜÇÏ°í, *.bak ÆÄÀÏÀ» ã¾Æ¶ó.
$ find . ! \( \( -path './foo/bar' -o -path './coffeenix/temp' \) -prune \) -name "*.bak"
$ find . ! \( \( -type d -path './foo/bar' -o -path './coffeenix/temp' \) -prune \) -name "*.bak" (º¸´Ù Á¤È®ÇÑ Ç¥Çö)
[¿¹Á¦ 4] ./2008·Î ½ÃÀÛÇÏ´Â µð·ºÅ丮´Â Á¦¿ÜÇÏ°í, .*.bak ÆÄÀÏÀ» ã¾Æ¶ó.
$ find . ! \( -path './2008*' -prune \) -name "*.bak"
$ find . ! \( -type d -path './2008*' -prune \) -name "*.bak" (º¸´Ù Á¤È®ÇÑ Ç¥Çö)
-path ´ë½Å -wholename ¿É¼ÇÀ» »ç¿ëÇصµ µÈ´Ù.
|
-path pattern
See -wholename. The predicate -path is also supported by HP-UX find.
-wholename pattern
File name matches shell pattern pattern. The metacharacters do not treat `/' or `.' specially; so, for example,
find . -wholename './sr*sc'
will print an entry for a directory called './src/misc' (if one exists). To ignore a whole directory tree, use -prune rather
than checking every file in the tree. For example, to skip the directory `src/emacs' and all files and directories under it,
and print the names of the other files found, do something like this:
find . -wholename './src/emacs' -prune -o -print
| |
2. Âü°íÀÚ·á
* find manpage
http://unixhelp.ed.ac.uk/CGI/man-cgi?find
* À¯¿ëÇÑ find ¸í·É¾î ¿¹ ¸ðÀ½ (2003, ±Û ÁÁÀºÁøÈ£)
http://coffeenix.net/board_view.php?bd_code=36
|