diff options
Diffstat (limited to 'ja/man/man1/expr.1')
-rw-r--r-- | ja/man/man1/expr.1 | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/ja/man/man1/expr.1 b/ja/man/man1/expr.1 new file mode 100644 index 0000000000..7caa681db5 --- /dev/null +++ b/ja/man/man1/expr.1 @@ -0,0 +1,140 @@ +.\" -*- nroff -*- +.\" +.\" Copyright (c) 1993 Winning Strategies, Inc. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Winning Strategies, Inc. +.\" 4. The name of the author may not be used to endorse or promote products +.\" derived from this software withough specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" %Id: expr.1,v 1.4 1996/01/29 22:53:24 mpp Exp % +.\" jpman %Id: expr.1,v 1.2 1997/04/03 02:39:40 mutoh Stab % +.\" +.Dd July 3, 1993 +.Dt EXPR 1 +.Os +.Sh 名称 +.Nm expr +.Nd 式を評価する +.Sh 書式 +.Nm expr +.Ar expression +.Sh 解説 +.Nm expr +は、与えられた式 +.Ar expression +を評価し、その結果を標準出力に書き出します。 +.Pp +.Nm expr +は、式で使われるすべての演算子を個別の引数として扱います。 +シェルが特殊キャラクタと解釈するような文字は、エスケープしておかなければ +なりません。 +.Pp +以下に、使える演算子を優先度の低い順に示します。 +同じ優先度の演算子は、{ } で括ってあります。 +.Bl -tag -width indent +.It Ar expr1 Li | Ar expr2 +.Ar expr1 +が空の文字列でも 0 でもない場合は +.Ar expr1 +を評価した結果を返し、さもなければ +.Ar expr2 +を評価した結果を返します。 +.It Ar expr1 Li & Ar expr2 +.Ar expr1 +と +.Ar expr2 +の各々の評価結果が、ともに空の文字列でも 0 でもない場合は +.Ar expr1 +を評価した結果を返し、さもなければ 0 を返します。 +.It Ar expr1 Li "{=, >, >=, <, <=, !=}" Ar expr2 +.Ar expr1 +と +.Ar expr2 +がともに整数ならば整数としての比較結果を返し、さもなければ +文字列とみなして、ロカールに従った照合方法を用いた比較結果を +返します。 +いずれの場合も、指定された関係が「真」ならば 1 を、「偽」ならば +0 を返します。 +.It Ar expr1 Li "{+, -}" Ar expr2 +整数値の引数に関して、加算あるいは減算した結果を返します。 +.It Ar expr1 Li "{*, /, %}" Ar expr2 +整数値の引数に関して、乗算、整数除算、または剰余の結果を返します。 +.It Ar expr1 Li : Ar expr2 +.Dq \: +演算子は、 +.Ar expr1 +と +.Ar expr2 +のパターンマッチを行います。 +.Ar expr2 +は、正規表現でなければなりません。 +またこの正規表現は、暗黙のうちに +.Dq ^ +が仮定されることにより、文字列の先頭から比較を始めることに +なります。 +.Pp +パターンマッチが成功した場合、もし正規表現中に少なくとも1つ +.Dq "\e(...\e)" +の形の部分正規表現が含まれていたならば、このうち +.Dq "\e1" +に相当する文字列を返します。 +このような部分正規表現が含まれていなければ、マッチした文字列の +長さを返します。 +またパターンマッチが失敗した場合、もし部分正規表現が含まれて +いたならば空の文字列を返し、含まれていない場合は 0 を返します。 +.El +.Pp +丸括弧 +.Dq "()" +は通常と同じくグループ分けに用いることができます。 +.Sh 使用例 +.Bl -enum +.It +以下の例は、変数 a に 1 を足します。 +.Dl a=`expr $a + 1` +.It +以下の例は、変数 a に設定されたパス名のうち、 +ファイル名に当たる部分を返します。 +文字列 // は、除算演算子との混同を防ぐために用います。 +.Dl expr "//$a" Li : '.*/\e(.*\e)' +.It +以下の例は、変数 a に含まれる文字の数を返します。 +.Dl expr $a Li : '.*' +.El +.Sh 診断 +.Nm expr +ユーティリティは、以下の値のうち1つを返して終了します。 +.Bl -tag -width Ds -compact +.It 0 +式は空文字列でも 0 でもない +.It 1 +式は空文字列か、0 であった +.It 2 +式が無効だった +.Sh 規格 +.Nm expr +ユーティリティは +.St -p1003.2 +準拠です。 |