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

¡ÎÌ¾Á°¡Ï
expr - °ú¿ô¤ò¼°¤È¤ß¤Ê¤·¤ÆÉ¾²Á

¡Î·Á¼°¡Ï
expr arg ...

¡Îµ¡Ç½ÀâÌÀ¡Ï
expr ¤Ï¡¢°ú¿ô¤ò¼°¤È¤ß¤Ê¤·¤ÆÉ¾²Á¤·¤Þ¤¹¡£É¾²Á¤µ¤ì¤¿·ë²Ì¤Ï¡¢É¸½à½ÐÎÏ¤Ë½ÐÎÏ¤µ¤ì¤Þ¤¹¡£
¶õÇòÊ¸»ú¤Ç¶èÀÚ¤é¤ì¤¿³Æ°ú¿ô¤¬¡¢¼°¤Î¥È¡¼¥¯¥ó¤È¤ß¤Ê¤µ¤ì¤Þ¤¹¡£¤·¤¿¤¬¤Ã¤Æ¡¢±é»»»Ò¤ÎÁ°¸å¤Ë¤â¶õÇòÊ¸»ú¤ò¤Ä¤±¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£

±é»»»Ò¤È¥­¡¼¥ï¡¼¥É¤Ï¡¢°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£°Ê²¼¤ÎÀâÌÀ¤Ï¡¢Í¥Àè½ç°Ì¤Î¼å¤¤½ç¤Ë¤ª¤³¤Ê¤¤¤Þ¤¹¡£Æ±¤¸¶¯¤µ¤Î±é»»»Ò¤Ï¡¢¤Ò¤È¤Þ¤È¤á¤Ë¤·¤Æ¤¢¤ê¤Þ¤¹¡£

expr | expr
ºÇ½é¤Î expr ¤¬¡¢¥Ì¥ëÊ¸»ú¤Þ¤¿¤Ï`0'¤Î¾ì¹ç¤Ï¡¢ºÇ½é¤Î expr ¤òÉ¾²Á¤·¤Þ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢ÆóÈÖÌÜ¤Î expr ¤òÉ¾²Á¤·¤Þ¤¹¡£

expr & expr
Î¾Êý¤Î expr ¤¬¡¢¥Ì¥ëÊ¸»ú¤Ç¤â`0'¤Ç¤â¤Ê¤¤¾ì¹ç¤Ï¡¢ºÇ½é¤Î expr ¤òÉ¾²Á¤·¤Þ¤¹¡£
¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢`0'¤òÊÖ¤·¤Þ¤¹¡£

expr relop expr
´Ø·¸±é»»»Ò relop ¤Ï¡¢< <= = != >= > ¤Î¤¤¤º¤ì¤«¤Ç¤¹¡£
Èæ³Ó¤Î·ë²Ì¤¬¿¿¤Î¤È¤­¤Ï¡¢ `1' ¤ò¡¢µ¶¤Î¤È¤­¤Ï¡¢ `0' ¤òÊÖ¤·¤Þ¤¹¡£Î¾Êý¤Î expr ¤¬À°¿ô¤Î¾ì¹ç¤Ï¡¢À°¿ôÃÍ¤ÎÈæ³Ó¤ò¤ª¤³¤Ê¤¤¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢Ê¸»úÎó¤Î¼­½ñ¼°½ç½ø¤Ë¤è¤ëÈæ³Ó¤ò¤ª¤³¤Ê¤¤¤Þ¤¹¡£

expr + expr
expr - expr
À°¿ôÃÍ¤Î°ú¿ô¤Î²Ã»»¤Þ¤¿¤Ï¸º»»¡£

expr * expr
expr / expr
expr % expr
À°¿ôÃÍ¤Î°ú¿ô¤Î¾è»»¡¢½ù»»¡¢¾êÍ¾·×»»¡£

expr : expr
match expr expr
°ìÃ×±é»»»Ò¤Ï¡¢ºÇ½é¤Î expr ¤òÊ¸»úÎó¡¢2 ÈÖÌÜ¤Î expr ¤òÀµµ¬É½¸½¤È²ò¼á¤·¡¢Èæ³Ó¤·¤Þ¤¹¡£Àµµ¬É½¸½¤Ï¡¢ed(1) ¤ÈÆ±ÍÍ¤Ç¤¹¡£
\(...\) ¤òÍÑ¤¤¤Æ¡¢ºÇ½é¤Î expr ¤«¤é°ìÉôÊ¬¤ò¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¡¢°ìÃ×±é»»»Ò¤Ï¡¢°ìÃ×¤·¤¿Ê¸»ú¿ô¤òÊÖ¤·¤Þ¤¹¡£( °ìÃ×¤¹¤ëÊ¸»ú¤¬¤Ê¤¤¾ì¹ç¤Ï¡¢ `0' ¤òÊÖ¤·¤Þ¤¹¡£)

index expr expr
2 ÈÖÌÜ¤Î expr Ãæ¤ÎÊ¸»ú¤¬¡¢ºÇ½é¤Î expr Æâ¤ËºÇ½é¤Ë¸½¤ì¤ë¾ì½ê(À°¿ôÃÍ)¤òÊÖ¤·¤Þ¤¹¡£(ºÇ½é¤ÎÊ¸»ú¤Ï¡¢`1' ÈÖÌÜ¤Ë¤Ê¤ê¤Þ¤¹¡£) °ìÃ×¤¹¤ëÊ¸»ú¤¬¤Ê¤¤¾ì¹ç¤Ï¡¢ `0' ¤òÊÖ¤·¤Þ¤¹¡£

substr expr index length
Ê¸»úÎó expr ¤Î index (À°¿ôÃÍ)ÌÜ¤«¤éÄ¹¤µ length (À°¿ôÃÍ)¤ÎÊ¸»úÎó¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£
( index ¤ÎºÇ½é¤ÎÊ¸»ú¤Ï¡¢`1' ÈÖÌÜ¤Ë¤Ê¤ê¤Þ¤¹¡£)

length expr
Ê¸»úÎó expr ¤ÎÄ¹¤µ(À°¿ôÃÍ)¤òÊÖ¤·¤Þ¤¹¡£

( expr )
¥°¥ë¡¼¥×²½¤Î¤¿¤á¤ËÍÑ¤¤¤ë¤«¤Ã¤³¡£

¡ÎÆüËÜ¸ìµ¡Ç½¡Ï
°ú¿ô¤Ë¡¢EUCÊ¸»ú¤¬¡¢»ÈÍÑ¤Ç¤­¤Þ¤¹¡£
¤¹¤Ù¤Æ¤Î½èÍý¤ÏÊ¸»ú¤´¤È¤Ë¤ª¤³¤Ê¤ï¤ì¤Þ¤¹¡£
Ê¸»ú¤Î½ç½ø¤Ï¡¢¥³¡¼¥É¥»¥Ã¥È½ç¤Ë¡¢

¥³¡¼¥É¥»¥Ã¥È 0 < ¥³¡¼¥É¥»¥Ã¥È 1 < ¥³¡¼¥É¥»¥Ã¥È 2 < ¥³¡¼¥É¥»¥Ã¥È 3

¤È¤·¤Þ¤¹¡£

¡Î»ÈÍÑÎã¡Ï

(Îã1) ¥·¥§¥ëÊÑ¿ô a ¤Ë 1 ¤ò²Ã¤¨¤Þ¤¹¡£

      a=`expr $a + 1`

(Îã2) ÊÑ¿ô a Ãæ¤Î¥Ñ¥¹Ì¾¤«¤é¥Õ¥¡¥¤¥ëÌ¾¤ÎÉôÊ¬( `/' ¤Ç¶èÀÚ¤é¤ì¤¿ºÇ¸å¤ÎÉôÊ¬)¤ò¼è¤ê½Ð¤·¤Þ¤¹¡£¥Ñ¥¹Ì¾¤Ë¤Ï¡¢`/' ¤¬´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¯¤Æ¤â¤«¤Þ¤¤¤Þ¤»¤ó¡£

      expr $a : '.*/\(.*\)' '|' $a

' ¤Ï¡¢¥·¥§¥ë¤Î¥á¥¿¥­¥ã¥é¥¯¥¿ | ¤ò¥¯¥©¡¼¥È¤¹¤ë¤¿¤áÉ¬Í×¤Ç¤¹¡£

(Îã3) 
      expr ¤¢¤¤¤¦ \> abc

¤ÈÆþÎÏ¤¹¤ë¤È¡¢"¤¢¤¤¤¦" ¤È "abc" ¤ò¼­½ñ¼°½ç½ø¤ÇÈæ³Ó¤·¤Æ¡¢

  1

¤¬½ÐÎÏ¤µ¤ì¤Þ¤¹¡£
\ ¤Ï¡¢¥·¥§¥ë¤Î¥á¥¿¥­¥ã¥é¥¯¥¿ > ¤ò¥¯¥©¡¼¥È¤¹¤ë¤¿¤áÉ¬Í×¤Ç¤¹¡£

¡Î´ØÏ¢¹àÌÜ¡Ï
ed(1), sh(1), test(1),
3.3J ¥ê¥ê¡¼¥¹¥Î¡¼¥È UNIX ¥³¥Þ¥ó¥É ¥é¥¤¥Ö¥é¥ê

¡Î¿ÇÃÇ¡Ï
Expr ¤Ï¡¢¼¡¤Î¤è¤¦¤Ê½ªÎ»¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£

  0    ¼°¤¬¥Ì¥ëÊ¸»ú¤Ç¤â `0' ¤Ç¤â¤Ê¤¤¾ì¹ç
  1    ¼°¤¬¥Ì¥ëÊ¸»ú¤Þ¤¿¤Ï `0' ¤Î¾ì¹ç
  2    ¼°¤¬Ìµ¸ú¤Î¾ì¹ç

¡ÎÃí°Õ»ö¹à¡Ï
match¡¢substr¡¢length¡¢index ¤Ï¡¢¥­¡¼¥ï¡¼¥É¤È¤·¤ÆÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢°ú¿ô¤ÎÊ¸»úÎó¥Ç¡¼¥¿¤È¤·¤ÆÍÑ¤¤¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£