1 .\" This file documents the GNU shell utilities.
3 .\" Copyright (C) 1994 Free Software Foundation, Inc.
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of
10 .\" this manual under the conditions for verbatim copying, provided that
11 .\" the entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Permission is granted to copy and distribute translations of this
15 .\" manual into another language, under the above conditions for modified
16 .\" versions, except that this permission notice may be stated in a
17 .\" translation approved by the Foundation.
19 .\" Japanese Version Copyright (c) 1997 NAKANO Takeo all rights reserved.
20 .\" Translated Thu May 12 1997 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
22 .\"WORD: lexicographic ¼½ñŪ¤Ê
24 .TH EXPR 1 "GNU Shell Utilities" "FSF" \" -*- nroff -*-
32 {\-\-help,\-\-version}
35 ¤³¤Îʸ½ñ¤Ï¤â¤¦¥á¥ó¥Æ¥Ê¥ó¥¹¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢ÉÔÀµ³Î¡¦ÉÔ´°Á´
36 ¤Ê²ÄǽÀ¤¬¤¢¤ë¡£¸½ºß¤Ï texinfo ʸ½ñ¤¬Àµ¼°¤Ê¾ðÊó¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
38 ¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ï GNU ÈÇ
40 ¤Ë¤Ä¤¤¤Æµ½Ò¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
42 ¤Ï¼°¤òɾ²Á¤·¤Æ¤½¤Î·ë²Ì¤òɸ½à½ÐÎϤ˽ñ¤½Ð¤¹¡£¼°¤Î¥È¡¼¥¯¥ó¤Ï¤½¤ì¤¾¤ìʬΥ
43 ¤·¤¿·Á¤Ç°ú¤¿ô¤ËÅϤ¹É¬Íפ¬¤¢¤ë¡£¥ª¥Ú¥é¥ó¥É¤Ï¿ô»ú¤«Ê¸»úÎó¤Ç¤¢¤ë¡£Ê¸»úÎó
46 ¤Ç¤Ï¥¯¥ª¡¼¥È¤·¤Ê¤¯¤Æ¤è¤¤¤¬¡¢¥·¥§¥ë¤«¤éÊݸ¤ë¤¿¤á¤Î°úÍÑÉ䤬ɬÍפ«¤â¤·
49 ¤Î¥ª¥Ú¥é¥ó¥É¤Î°ÌÃÖ¤ËÃÖ¤«¤ì¤¿¤â¤Î¤Ï¡¢¤½¤Î¥ª¥Ú¥é¥ó¥É¤ËÂФ¹¤ë±é»»¤Ë±þ¤¸¤Æ
50 ¿ôÃͤޤ¿¤Ïʸ»úÎó¤È¤ß¤Ê¤µ¤ì¤ë¡£
52 ±é»»»Ò¤Ï°Ê²¼¤ÎÄ̤ê¡ÊÍ¥ÀèÅ٤ι⤤½ç¡Ë:
54 º¸¹à¤¬¥Ì¥ë¤Ç¤â 0 ¤Ç¤â¤Ê¤±¤ì¤Ðº¸¹à¤òÊÖ¤¹¡£¥Ì¥ë¤ä 0 ¤À¤Ã¤¿¾ì¹ç¤Ï±¦¹à¤òÊÖ
55 ¤¹¡£¤³¤ì¤ÏÄ̾ï¤Î `or' ±é»»¤Ç¤¢¤ë¡£
57 º¸¹à¡¢±¦¹à¤È¤â¥Ì¥ë¤Ç¤â 0 ¤Ç¤â¤Ê¤±¤ì¤Ðº¸¹à¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï 0 ¤È
59 .IP "\fI<\fP\0 \fI<=\fP\0 \fI=\fP\0 \fI==\fP\0 \fI!=\fP\0 \fI>=\fP\0 \fI>\fP"
60 ξ¹à¤òÈæ³Ó¤·¡¢´Ø·¸¤¬¿¿¤Ê¤é 1¡¢µ¶¤Ê¤é 0 ¤òÊÖ¤¹¡Ê\fI==\fP ¤Ï \fI=\fP
62 \fBexpr\fP ¤Ï¤Þ¤ºÎ¾Êý¤Î¹à¤ò¿ôÃͤȤߤʤ·¡¢¿ôÃͥǡ¼¥¿¤È¤·¤Æ¤ÎÈæ³Ó¤ò¹Ô¤ª
63 ¤¦¤È¤¹¤ë¡£¤³¤ì¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¡¢¼½ñŪ¤ÊÈæ³Ó¤ò¹Ô¤¦¡£
64 .IP "\fI+\fP\0 \fI-\fP"
65 Âå¿ô±é»»¤ò¹Ô¤¦¡£º¸±¦¤Î¹à¤Ï¿ôÃͤȤߤʤµ¤ì¡¢¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¥¨¥é¡¼¤È¤Ê¤ë¡£
66 .IP "\fI*\fP\0 \fI/\fP\0 \fI%\fP"
67 Âå¿ô±é»»¤ò¹Ô¤¦¡Ê`%' ¤Ï C ¤Î¾ì¹ç¤ÈƱ¤¸¤¯¾ê;±é»»¤ËÂбþ¤¹¤ë¡Ë¡£º¸±¦¤Î¹à
68 ¤Ï¿ôÃͤȤߤʤµ¤ì¡¢¤³¤ì¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¥¨¥é¡¼¤È¤Ê¤ë¡£
70 ¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ò¼Â¹Ô¤¹¤ë¡£º¸±¦¤Î¹à¤Ïʸ»úÎó¤Ç¤¢¤ë¤È¤ß¤Ê¤µ¤ì¡¢±¦¹à¤ÏÀµµ¬
71 ɽ¸½¤È¤·¤Æ°·¤ï¤ì¤ë¡£±¦¹à¤Ë¤Ï°ÅÌۤΤ¦¤Á¤ËÀèƬ¤Ë `^' ¤¬¼«Æ°Åª¤ËÉղ䵤졢
72 º¸¹à¤¬¤½¤ÎÀµµ¬É½¸½¤Ë¥Þ¥Ã¥Á¤¹¤ë¤«¤Î¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤ë¡£¥Þ¥Ã¥Á¤¬À®¸ù¤·¤¿¾ì
73 ¹ç¡¢Àµµ¬É½¸½¤Î°ìÉô¤¬ `\e(' ¤È '\e)' ¤Ç°Ï¤ï¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¤½¤ÎÉôʬ¤¬
75 ¤ÎÊÖ¤êÃͤȤʤꡢ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¥Þ¥Ã¥Á¤·¤¿Éôʬ¤Îʸ»ú¿ô¤¬ÊÖ¤µ¤ì¤ë¡£¥Þ¥Ã
76 ¥Á¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¡¢ `\e(' ¤È `\e)' ¤¬»È¤ï¤ì¤Æ¤¤¤¿¾ì¹ç¤Ë¤Ï¥Ì¥ëʸ»ú¤¬¡¢¤½
77 ¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£ `\e(' ¤È `\e)' ¤Î¥Ú¥¢¤Ï°ì¤Ä¤À¤±¤·¤«»È
80 ¤µ¤é¤Ë¡¢°Ê²¼¤Î¤è¤¦¤Ê¥¡¼¥ï¡¼¥É¤¬Ç§¼±¤µ¤ì¤ë:
82 .BI match " string regex"
83 ¥Ñ¥¿¡¼¥ó¥Þ¥Ã¥Á¤ò¹Ô¤¦Ê̤Τä¤êÊý¡£¤³¤ì¤Ï
84 ``\fIstring\fP \fB:\fP \fIregex\fP'' ¤ÈƱ¤¸¡£
86 .BI substr " string position length"
87 \fIstring\fP ¤ÎÉôʬʸ»úÎó¤òÊÖ¤¹¡£Éôʬʸ»úÎó¤Ï \fIstring\fP ¤Î
88 \fIposition\fP ¤«¤é»Ï¤Þ¤ê¡¢ºÇÂç \fIlength\fP ¤ÎŤµ¤ò»ý¤Ä¡£
89 \fIposition\fP ¤Þ¤¿¤Ï \fIlength\fP ¤¬É餫¿ôÃͰʳ°¤Î¾ì¹ç¤Ï¡¢¥Ì¥ëʸ»úÎó
92 .BI index " string character-class"
93 \fIstring\fP ¤Î¤¦¤Á¡¢\fIcharacter-class\fP ¤ÎÃæ¤Î¤É¤ì¤«¤Îʸ»ú¤¬¸«¤Ä¤«¤Ã
94 ¤¿ºÇ½é¤Î°ÌÃÖ¤òÊÖ¤¹¡£ \fIstring\fP ¤ÎÃæ¤Ë \fIcharacter-class\fP ¤Î¤É¤ì
95 ¤â¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤¹¡£
101 ³ç¸Ì¤òÍѤ¤¤Æ±é»»¤ò¥°¥ë¡¼¥×²½¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£¥¡¼¥ï¡¼¥É¤Ïʸ»úÎó¤È¤·¤Æ
102 ÍѤ¤¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
106 ¤¬°ú¤¿ô°ì¤Ä¤Ç¼Â¹Ô¤µ¤ì¤¿¤È¤¤Ë¸Â¤ê¡¢°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤¬Ç§¼±¤µ¤ì¤ë:
109 »È¤¤Êý¤Ë´Ø¤¹¤ë¥á¥Ã¥»¡¼¥¸¤òɸ½à½ÐÎϤËɽ¼¨¤·¡¢¼Â¹ÔÀ®¸ù¤òÊÖ¤·¤Æ½ªÎ»¤¹¤ë¡£
112 ¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤òɸ½à½ÐÎϤËɽ¼¨¤·¡¢¼Â¹ÔÀ®¸ù¤òÊÖ¤·¤Æ½ªÎ»¤¹¤ë¡£
117 ¤Ë 1 ¤ò²Ã¤¨¤ë¤Ë¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤¹¤ë:
123 ¤ËÆþ¤Ã¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë̾¤Î¤¦¤Á¡¢¥Ç¥£¥ì¥¯¥È¥ê°Ê³°¤ÎÉôʬ¤òɽ¼¨¤¹¤ë¤Î¤ËÍѤ¤
127 ¤Ë `/' ¤¬´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¯¤Æ¤âÎɤ¤¡Ë:
129 expr $a : \'.*/\e(\^.*\e)\' \'\^|\' $a
131 ¥·¥§¥ë¤Î¥á¥¿¥¥ã¥é¥¯¥¿¤ò¥¯¥ª¡¼¥È¤·¤Æ¤¤¤ë¤³¤È¤ËÃí°Õ¡£
134 ¤Ï½ªÎ»»þ¤Ë°Ê²¼¤Î¤è¤¦¤ÊÃͤòÊÖ¤¹¡£
136 0: ¼°¤¬¥Ì¥ë¤Ç¤â 0 ¤Ç¤â¤Ê¤«¤Ã¤¿¾ì¹ç¡£
138 1: ¼°¤¬¥Ì¥ë¤Þ¤¿¤Ï 0 ¤À¤Ã¤¿¾ì¹ç¡£
140 2: ¼°¤¬Àµ¤·¤¯¤Ê¤«¤Ã¤¿¾ì¹ç¡£