GREP(1)		UNIX ¥³¥Þ¥ó¥É	GREP(1)

¡ÎÌ¾Á°¡Ï
grep, egrep, fgrep  - ¥Õ¥¡¥¤¥ë¤ÎÊ¸»úÎó¤Þ¤¿¤ÏÀµµ¬É½¸½¤Î¥µ¡¼¥Á

¡Î·Á¼°¡Ï
grep [ option ] ...  expression [ file ] ...
egrep [ option ] ...  [ expression ] [ file ] ...
fgrep [ option ] ...  [ strings ] [ file ]

¡Îµ¡Ç½ÀâÌÀ¡Ï
grep¥Õ¥¡¥ß¥ê¤Î¥³¥Þ¥ó¥É¤Ï¡¢ÆþÎÏ¥Õ¥¡¥¤¥ë¡Ê¥Ç¥Õ¥©¥ë¥È¤ÏÉ¸½àÆþÎÏ¡Ë¤ò¥Ñ¥¿¡¼¥ó¸¡º÷¤·¤Æ¡¢¤½¤Î¥Ñ¥¿¡¼¥ó¤ò´Þ¤à¹Ô¤ò¤¹¤Ù¤ÆÉ¸½à½ÐÎÏ¤Ë½ÐÎÏ¤·¤Þ¤¹¡£grep¤¬¾È¹ç¤Ë»ÈÍÑ¤¹¤ë¥Ñ¥¿¡¼¥ó¤Ïed(1)¤Ç»ÈÍÑ¤¹¤ë¸ÂÄêÀµµ¬É½¸½¤Ç¤¢¤ê¡¢¥³¥ó¥Ñ¥¯¥È¤ÊÈó·èÄêÏÀÅª¥¢¥ë¥´¥ê¥º¥à¤ò»ÈÍÑ¤·¤Æ¤¤¤Þ¤¹¡£egrep¤Î¥Ñ¥¿¡¼¥ó¤Ï´°Á´¤ÊÀµµ¬É½¸½¤Ç¤¢¤ê»þ¤Ë¤è¤Ã¤Æ¤Ï»Ø¿ôÅª¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤òÉ¬Í×¤È¤¹¤ë¹âÂ®¤Î·èÄêÏÀÅª¥¢¥ë¥´¥ê¥º¥à¤ò»ÈÍÑ¤·¤Æ¤¤¤Þ¤¹¡£fgrep¤Î¥Ñ¥¿¡¼¥ó¤Ï¸ÇÄê¤ÎÊ¸»úÎó¤Ç¤¢¤ê¡¢¹âÂ®¤Ç´ÊÊØ¤Ç¤¹¡£°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤¬Ç§¼±¤µ¤ì¤Þ¤¹¡£

-v	
°ìÃ×¤·¤¿¹Ô¤ò½ü¤¯Á´¹Ô¤ò½ÐÎÏ¤·¤Þ¤¹¡£

-x	
¹ÔÁ´ÂÎ¤¬°ìÃ×¤·¤¿¹Ô¤À¤±¤ò½ÐÎÏ¤·¤Þ¤¹¡£¡Êfgrep¤Î¤ß¡Ë

-c	
°ìÃ×¤·¤¿¹Ô¤Î¹Ô¿ô¤Î¤ß¤ò½ÐÎÏ¤·¤Þ¤¹¡£

-l	
°ìÃ×¤·¤¿¹Ô¤¬¤¢¤ë¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ëÌ¾¤À¤±¤òÉüµ¢²þ¹Ô¤Ç¶èÀÚ¤Ã¤Æ½ÐÎÏ¤·¤Þ¤¹¡£¡Ê1ÅÙ¤Å¤Ä¡Ë

-n	
³Æ¹Ô¤ÎÀèÆ¬¤Ë¥Õ¥¡¥¤¥ëÆâ¤ÎÁêÂÐÈÖ¹æ¤ò½ÐÎÏ¤·¤Þ¤¹¡£

-b	
³Æ¹Ô¤ÎÀèÆ¬¤Ë¤½¤Î¹Ô¤¬¤¢¤ë¥Ö¥í¥Ã¥¯ÈÖ¹æ¤ò¤¤¤ì¤Þ¤¹¡£¤³¤ì¤Ï¡¢¤È¤­¤Ë¤è¤Ã¤ÆÊ¸Ì®¤Ë¤è¤ê¥Ç¥£¥¹¥¯¤Î¥Ö¥í¥Ã¥¯ÈÖ¹æ¤ò¸«¤Ä¤±¤À¤¹¾ì¹ç¤ËÊØÍø¤Ç¤¹¡£

-i	
Èæ³Ó¤Î»þ¤ËÂç¾®Ê¸»ú¤ò¶èÊÌ¤·¤Þ¤»¤ó¡£¡Êgrep¡¢fgrep¤Î¤ßÂÐ±þ¡Ë

-s
¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤À¤±¤ò½ÐÎÏ¤·¤Þ¤¹¡£¥¨¥é¡¼¾õÂÖ¤òÄ´¤Ù¤ë¤Î¤ËÊØÍø¤Ç¤¹¡£

-w	
\<¤È\>¤Ç°Ï¤ó¤À¤Î¤ÈÆ±¤¸ÍÍ¤Ë¼°¤ò¥ï¡¼¥É¤È¤·¤Æ¥µ¡¼¥Á¤·¤Þ¤¹¡£¡Êex(1)¤ò»²¾È¡£grep¤Î¤ß¡Ë	
-e expression
Ã±¤Ëexpression¤Î¤ß¤ò»ØÄê¤·¤¿¤È¤­¤ÈÆ±¤¸¤Ç¤¹¤¬expression¤¬'_'¤Ç»Ï¤Þ¤ë¾ì¹ç¤Ë»ÈÍÑ¤·¤Þ¤¹¡£

-f file
Àµµ¬É½¸½¡Êegrep)¤äÊ¸»úÎó¤Î¥ê¥¹¥È¡Êfgrep¡Ë¤ò¥Õ¥¡¥¤¥ë¤«¤é¤È¤ê¤À¤·¤Þ¤¹¡£

¤¤¤º¤ì¤Î¾ì¹ç¤Ë¤â¡¢Ê£¿ô¤ÎÆþÎÏ¥Õ¥¡¥¤¥ë¤¬¤¢¤ë»þ¤Ï¥Õ¥¡¥¤¥ëÌ¾¤¬½ÐÎÏ¤µ¤ì¤Þ¤¹¡£expression¤Ç $¡¢*¡¢[¡¢^¡¢|¡¢(¡¢)¡¢\¤ÎÍÍ¤ÊÊ¸»ú¤ò»ÈÍÑ¤¹¤ë»þ¤ÏÃí°Õ¤¬É¬Í×¤Ç¤¹¡£¤³¤ì¤é¤ÎÊ¸»ú¤Ï¥·¥§¥ë¤Ë¤È¤Ã¤Æ¤â°ÕÌ£¤¬¤¢¤ë¤«¤é¤Ç¤¹¡£expressionÁ´ÂÎ¤òÃ±°ì°úÍÑÉä' '¤Ç°Ï¤à¤Î¤¬°ÂÁ´¤Ç¤¹¡£

fgrep¤ÏÉüµ¢²þ¹Ô¤Ç¶èÀÚ¤é¤ì¤¿°ì¤Ä¤ÎÊ¸»úÎó¤È°ìÃ×¤¹¤ë¹Ô¤ò¸¡º÷¤·¤Þ¤¹¡£

egrep¤Ï³ÈÄ¥¤µ¤ì¤¿Àµµ¬É½¸½¤ò¤¦¤±¤¤¤ì¤Þ¤¹¡£¼¡¤ÎÀâÌÀ¤ÎÃæ¤ÎÊ¸»ú¤ÏÉüµ¢²þ¹Ô¤ò½ü¤­¤Þ¤¹¡£

\¤Î¸å¤ËÂ³¤¯Éüµ¢²þ¹Ô°Ê³°¤Î1Ê¸»ú¤Ï¤½¤ÎÊ¸»ú¤È°ìÃ×¤·¤Þ¤¹¡£

^¤Ï¹Ô¤ÎºÇ½é¤È°ìÃ×¤·¤Þ¤¹¡£

$¤Ï¹Ô¤Î½ª¤ï¤ê¤È°ìÃ×¤·¤Þ¤¹¡£

.¤ÏÇ¤°Õ¤ÎÊ¸»ú¤È°ìÃ×¤·¤Þ¤¹¡£

ÆÃÊÌ¤Ê°ÕÌ£¤Î¤Ê¤¤1Ê¸»ú¤Ï¤½¤ÎÊ¸»ú¤È°ìÃ×¤·¤Þ¤¹¡£

[]¤Ç°Ï¤Þ¤ì¤¿Ê¸»úÎó¤Ï¤½¤ÎÃæ¤ÎÇ¤°Õ¤Î1Ê¸»ú¤È°ìÃ×¤·¤Þ¤¹¡£ASCIIÊ¸»ú¥³¡¼¥É¤Ï'a-z0-9'¤ÎÍÍ¤Ë¾ÊÎ¬¤·¤ÆÈÏ°Ï»ØÄê¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£]¤ÏÊ¸»úÎó¤ÎºÇ½é¤Ë¤¢¤ë¾ì¹ç¤Î¤ßÇ§¤á¤é¤ì¤Þ¤¹¡£Ê¸»ú¤È¤·¤Æ¤Î]h¤ÏÈÏ°Ï»ØÄê¤Î°Ù¤Î¤â¤Î¤È´Ö°ã¤¨¤é¤ì¤Ê¤¤¾ì½ê¤ËÃÖ¤«¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£

*¤ËÂ³¤¯Àµµ¬É½¸½¤Ï¤½¤ÎÀµµ¬É½¸½¤¬0²ó°Ê¾å¸½¤ì¤¿¤â¤Î¤È°ìÃ×¤·¤Þ¤¹¡£
+¤ËÂ³¤¯Àµµ¬É½¸½¤Ï¤½¤ÎÀµµ¬É½¸½¤¬1²ó°Ê¾å¸½¤ì¤¿¤â¤Î¤È°ìÃ×¤·¤Þ¤¹¡£
?¤ËÂ³¤¯Àµµ¬É½¸½¤Ï¤½¤ÎÀµµ¬É½¸½¤¬0¤Þ¤¿¤Ï1²ó°Ê¾å¸½¤ì¤¿¤â¤Î¤È°ìÃ×¤·¤Þ¤¹¡£

¤«¤Ã¤³()¤Ç°Ï¤Þ¤ì¤¿Àµµ¬É½¸½¤Ï¡¢Àµµ¬É½¸½¤½¤ì¼«ÂÎ¤È°ìÃ×¤¹¤ë¤â¤Î¤È°ìÃ×¤·¤Þ¤¹¡£

±é»»»Ò¤ÎÍ¥Àè½ç°Ì¤Ï[]¡¢¼¡¤Ë*?+ ¤Ç¤¹¡£

¡ÎÆüËÜ¸ìµ¡Ç½¡Ï
grep¥Õ¥¡¥ß¥ê¤ÏEUCÊ¸»úÎó¤ò´Þ¤à¥Õ¥¡¥¤¥ë¤ò¥µ¡¼¥Á¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤Ï¥Ð¥¤¥ÈÃ±°Ì¤Ç¤Ï¤Ê¤¯Ê¸»úÃ±°Ì¤Ç¹Ô¤ï¤ì¤Þ¤¹¡£

Àµµ¬É½¸½¤Î¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¥ó¥°¤Î¾ì¹ç¤Ï¡¢ÆÃ¼ìÊ¸»ú¤Ï¼ç¥³¡¼¥É¥»¥Ã¥È¤Ë´Þ¤Þ¤ì¤ë¤â¤Î¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£Âç³ç¸Ì¤Ç°Ï¤ó¤ÀÊ¸»ú¥³¡¼¥ÉÈÏ°Ï¤ò»ÈÍÑ¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢ÈÏ°Ï¤Î»ÏÅÀ¤È½ªÅÀ¤Ë¤ÏÆ±¤¸¥³¡¼¥É¥»¥Ã¥È¤ÎÊ¸»ú¤ò»ÈÍÑ¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£Æ±¤¸¥³¡¼¥É¥»¥Ã¥È¤ËÂ°¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢Î¾Ã¼¤È¤·¤Æ»ØÄê¤·¤¿¶­³¦Ê¸»ú¤À¤±¤¬ÂÐ¾Ý¤È¤Ê¤ê¤Þ¤¹¡£

Îã)
[°¡-´Á]¤ÏNJE¥³¡¼¥É¥»¥Ã¥È¤Ë¤ª¤¤¤Æ°¡(0xb0a1)¤«¤é´Á(0xb4c1)¤ÎÈÏ°Ï¤Ë¤¢¤ë´Á»ú¤ò¼¨¤·¤Þ¤¹¡£[£±-´Á]¤Ï£±¤«¤é´Á¤Þ¤Ç¤ÎÈÏ°Ï¤Ç¤¢¤êÁ´³Ñ¤Î¾ì¹çÆÃ¤ËÊ¸»ú¼ï¤Î¶èÊÌ¤Ï¤·¤Þ¤»¤ó¡£ ¤Þ¤¿¡¢[´Á-°¡]¤ÎÍÍ¤Ë»ØÄê¤µ¤ì¤¿¤È¤­¤Ï¶­³¦Ê¸»ú ´Á¤È°¡¤Î¤ß¤È°ìÃ×¤·¤Þ¤¹¡£Æ±ÍÍ¤Ë [1-´Á]¡¢[´Á-a]Åù°Û¤Ê¤ë¥³¡¼¥É¥»¥Ã¥È¤ò»ØÄê¤µ¤ì¤¿»þ¤â¶­³¦Ê¸»ú¤Î¤ß¤È°ìÃ×¤·¤Þ¤¹¡£

¡Î»ÈÍÑÎã¡Ï
grep £±£²\[¤¢-´Á\]»ú file
'£±£²'¤Ç»Ï¤Þ¤ê3Ê¸»úÌÜ¤¬'¤¢'¤«¤é'´Á'¤Þ¤Ç¤ÎÈÏ°Ï¤Ë¤¢¤ê4Ê¸»úÌÜ¤¬'»ú'¤Ç¤¢¤ëÊ¸»úÎó¤ò'file'¤è¤ê¸¡º÷¤·¤½¤ì¤¬´Þ¤Þ¤ì¤ë¹Ô¤òÉ½¼¨¤·¤Þ¤¹¡£

¡Î´ØÏ¢¹àÌÜ¡Ï
bm(1), ex(1), sed(1), sh(1)

¡Î¿ÇÃÇ¡Ï
½ªÎ»¥¹¥Æ¡¼¥¿¥¹¤Î0¤Ï°ìÃ×¤¹¤ë¤â¤Î¤¬¤¢¤Ã¤¿¾ì¹ç¡¢1¤Ï¤Ê¤«¤Ã¤¿¾ì¹ç¡¢2¤Ï¥·¥ó¥¿¥Ã¥¯¥¹¥¨¥é¡¼¤Þ¤¿¤Ï¥¢¥¯¥»¥¹½ÐÍè¤Ê¤¤¥Õ¥¡¥¤¥ë¤¬»ØÄê¤µ¤ì¤¿¾ì¹ç¡£

¡ÎÃí°Õ»ö¹à¡Ï
grep¥°¥ë¡¼¥×¤ÎÂÐ¾Ý¤È¤¹¤ë¥Õ¥¡¥¤¥ë¤ÏNJE¥³¡¼¥É¥»¥Ã¥È¤Ëµ¬Äê¤µ¤ì¤ë¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤Î¤ß¤Ç¤¹¡£Latin1¤ÎÊ¸»ú¤¬´Þ¤Þ¤ì¤ë¥Õ¥¡¥¤¥ë¡¢¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤òÂÐ¾Ý¤È¤·¤¿»þ¤ÎÆ°ºî¤ÏÊÝ¾Ú¤µ¤ì¤Þ¤»¤ó¡£
1¹Ô¤Ï256¥Ð¥¤¥È¤Þ¤Ç¤Ç¤¢¤ê¤½¤ì°Ê¾å»ØÄê¤µ¤ì¤¿»þ¤ÏÀÚ¤ê¼Î¤Æ¤é¤ì¤Þ¤¹¡£