expr

EXPR(1)                     General Commands Manual                    EXPR(1)



åå
       expr - å¼ãè©ä¾¡ãã

æ¸å¼
       expr expression...
       expr {--help,--version}

説æ
       ãã®ææ¸ã¯ããã¡ã³ããã³ã¹ããã¦ããªãã®ã§ãä¸æ£ç¢ºã»ä¸å®å¨ ãªå¯è½æ§ããããç¾å¨ã¯
       texinfo ææ¸ãæ£å¼ãªæå ±ã¨ãªã£ã¦ããã

       ãã®ããã¥ã¢ã«ãã¼ã¸ã¯ GNU ç expr ã«ã¤ãã¦è¨è¿°ãããã®ã§ããã expr
       ã¯å¼ãè©ä¾¡ãã¦ãã®çµæãæ¨æºåºåã«æ¸ãåºããå¼ã®ãã¼ã¯ã³ã¯ããããåé¢
       ããå½¢ã§å¼ãæ°ã«æ¸¡ãå¿è¦ãããããªãã©ã³ãã¯æ°åãæååã§ãããæåå 㯠expr
       ã§ã¯ã¯ãªã¼ãããªãã¦ããããã·ã§ã«ããä¿è·ããããã®å¼ç¨ç¬¦ãå¿è¦ããã ããªãã expr
       ã®ãªãã©ã³ãã®ä½ç½®ã«ç½®ããããã®ã¯ããã®ãªãã©ã³ãã«å¯¾ããæ¼ç®ã«å¿ãã¦
       æ°å¤ã¾ãã¯æååã¨ã¿ãªãããã

       æ¼ç®åã¯ä»¥ä¸ã®éãï¼åªå度ã®é«ãé ï¼:

       |      å·¦é ããã«ã§ã 0 ã§ããªããã°å·¦é ãè¿ãããã«ã 0 ã ã£ãå ´åã¯å³é ãè¿
              ããããã¯é常㮠`or' æ¼ç®ã§ããã

       &      å·¦é ãå³é ã¨ããã«ã§ã 0 ã§ããªããã°å·¦é ãè¿ãããã以å¤ã®å ´å㯠0 ã¨
              ãªãã

       <  <=  =  ==  !=  >=  >
              両é ãæ¯è¼ããé¢ä¿ãçãªã 1ãå½ãªã 0 ãè¿ãï¼== 㯠= ã¨å義ï¼ã expr
              ã¯ã¾ã両æ¹ã®é ãæ°å¤ã¨ã¿ãªããæ°å¤ãã¼ã¿ã¨ãã¦ã®æ¯è¼ãè¡ã
              ãã¨ãããããã«å¤±æããå ´åã¯ãè¾æ¸çãªæ¯è¼ãè¡ãã

       +  -   代æ°æ¼ç®ãè¡ããå·¦å³ã®é ã¯æ°å¤ã¨ã¿ãªããã失æããå ´åã¯ã¨ã©ã¼ã¨ãªãã

       *  /  %
              代æ°æ¼ç®ãè¡ãï¼`%' 㯠C ã®å ´åã¨åããå°ä½æ¼ç®ã«å¯¾å¿ããï¼ãå·¦å³ã®é
              ã¯æ°å¤ã¨ã¿ãªãããããã«å¤±æããå ´åã¯ã¨ã©ã¼ã¨ãªãã

       :      ãã¿ã¼ã³ããããå®è¡ãããå·¦å³ã®é ã¯æååã§ããã¨ã¿ãªãããå³é ã¯æ£è¦
              表ç¾ã¨ãã¦æ±ããããå³é ã«ã¯æé»ã®ãã¡ã«åé ã« `^' ãèªåçã«ä»å ããã
              å·¦é ããã®æ£è¦è¡¨ç¾ã«ããããããã®ãã¹ããè¡ããããããããæåããå ´ åãæ‐
              £è¦è¡¨ç¾ã®ä¸é¨ã `\(' 㨠'\)' ã§å²ããã¦ããå ´åã«ã¯ãã®é¨åã :
              ã®è¿ãå¤ã¨ãªãããã以å¤ã®å ´åã¯ãããããé¨åã®æåæ°ãè¿ãããããã
              ãã«å¤±æããå ´åã `\(' 㨠`\)' ã使ããã¦ããå ´åã«ã¯ãã«æåããã
              ãã§ãªãå ´åã«ã¯ 0 ãè¿ãããã `\(' 㨠`\)' ã®ãã¢ã¯ä¸ã¤ã ããã使
              ããã¨ãã§ããªãã

       ããã«ã以ä¸ã®ãããªãã¼ã¯ã¼ããèªèããã:

       match string regex
              ãã¿ã¼ã³ããããè¡ãå¥ã®ããæ¹ããã㯠``string : regex'' ã¨åãã

       substr string position length
              string ã®é¨åæååãè¿ããé¨åæåå㯠string ã® position ããå§ã¾ããæ大
              length ã®é·ããæã¤ã position ã¾ã㯠length
              ãè² ãæ°å¤ä»¥å¤ã®å ´åã¯ããã«æåå ãè¿ãã

       index string character-class
              string ã®ãã¡ãcharacter-class ã®ä¸ã®ã©ããã®æåãè¦ã¤ãã£
              ãæåã®ä½ç½®ãè¿ãã string ã®ä¸ã« character-class ã®ã©ã
              ããªãã£ãå ´å㯠0 ãè¿ãã

       length string
              string ã®é·ããè¿ãã

       æ¬å¼§ãç¨ãã¦æ¼ç®ãã°ã«ã¼ãåãããã¨ãã§ããããã¼ã¯ã¼ãã¯æååã¨ã㦠ç¨ãããã¨ã¯ã§ããªãã

   ãªãã·ã§ã³
       GNU expr ãå¼ãæ°ä¸ã¤ã§å®è¡ãããã¨ãã«éãã以ä¸ã®ãªãã·ã§ã³ãèªèããã:

       --help 使ãæ¹ã«é¢ããã¡ãã»ã¼ã¸ãæ¨æºåºåã«è¡¨ç¤ºããå®è¡æåãè¿ãã¦çµäºããã

       --version
              ãã¼ã¸ã§ã³æå ±ãæ¨æºåºåã«è¡¨ç¤ºããå®è¡æåãè¿ãã¦çµäºããã

ä¾
       ã·ã§ã«å¤æ° a ã« 1 ãå ããã«ã¯ä»¥ä¸ã®ããã«ãã:

              a=`expr $a + 1`

       以ä¸ã¯å¤æ° a
       ã«å¥ã£ã¦ãããã¡ã¤ã«åã®ãã¡ããã£ã¬ã¯ããªä»¥å¤ã®é¨åã表示ããã®ã«ç¨ã ããã¨ãã§ããã
       ï¼ a ã« `/' ãå«ã¾ãã¦ããªãã¦ãè¯ãï¼:

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

       ã·ã§ã«ã®ã¡ã¿ãã£ã©ã¯ã¿ãã¯ãªã¼ããã¦ãããã¨ã«æ³¨æã

       expr ã¯çµäºæã«ä»¥ä¸ã®ãããªå¤ãè¿ãã

       0: å¼ããã«ã§ã 0 ã§ããªãã£ãå ´åã
       1: å¼ããã«ã¾ã㯠0 ã ã£ãå ´åã
       2: å¼ãæ£ãããªãã£ãå ´åã



FSF                           GNU Shell Utilities                      EXPR(1)