.\"O .TH WHICH 1 .\"O .rn RS Rs .\"O .de RS .\"O .na .\"O .nf .\"O .Rs .\"O .. .\"O .rn RE Re .\"O .de RE .\"O .Re .\"O .fi .\"O .ad .\"O .. .\"O .de Sx .TH WHICH 1 .rn RS Rs .de RS .na .nf .Rs .. .rn RE Re .de RE .Re .fi .ad .. .de Sx .\"O ---------------------------------------- .\"O .PP .\"O .ne \\$1 .PP .ne \\$1 .\"O ---------------------------------------- .\"O .RS .\"O .. .\"O .de Ex .RS .. .de Ex .\"O ---------------------------------------- .\"O .RE .RE .\"O ---------------------------------------- .\"O .PP .\"O .. .\"O .na .PP .. .na .\"O ---------------------------------------- .\"O .SH NAME .\"O which \- shows the full path of (shell) commands. .SH 名前 which \- (シェル) コマンドのフルパスを表示します .\"O ---------------------------------------- .\"O .SH SYNOPSIS .\"O .B which .\"O [options] [\-\-] programname [...] .SH 書式 \fBwhich\fP [options] [\-\-] programname [...] .\"O ---------------------------------------- .\"O .SH DESCRIPTION .\"O \fBWhich\fR takes one or more arguments. For each of its arguments .\"O it prints to stdout the full path of the executables .\"O that would have been executed when this argument had been .\"O entered at the shell prompt. It does this by searching .\"O for an executable or script in the directories listed in .\"O the environment variable \fBPATH\fR using the same algorithm as \fBbash(1)\fR. .SH 説明 \fBwhich\fP は 1 つまたは複数の引数を取ります。 その引数それぞれに対して、その引数がシェルプロンプトから入力された際に、実行されることになる実行モジュールのフルパスを stdout に出力します。 これを実現する際には、環境変数 \fBPATH\fP に列記されたディレクトリ内から実行ファイルやスクリプトを検索します。 これは \fBbash(1)\fP と同じアルゴリズムを用いています。 .\"O ---------------------------------------- .\"O .\"O This man page is generated from the file \fIwhich.texinfo\fR. この man ページは \fIwhich.texinfo\fP ファイルから生成されています。 .\"O ---------------------------------------- .\"O .SH OPTIONS .SH オプション .\"O ---------------------------------------- .\"O ---------------------------------------- .\"O .TP 4 .\"O .B --all\fR, \fB-a\fR .\"O Print all matching executables in \fBPATH\fR, not just the first. .TP 4 \fB\-\-all\fP, \fB\-a\fP \fBPATH\fP 内に見つかった実行ファイルすべてを表示します。 最初に見つかったもの以外も表示します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --read-alias\fR, \fB-i\fR .\"O Read aliases from stdin, reporting matching ones on .\"O stdout. This is useful in combination with using an .\"O alias for which itself. For example .\"O .br .\"O .B .\"O alias which=\'alias | which -i\'\fR. .TP \fB\-\-read\-alias\fP, \fB\-i\fP 標準入力からエイリアスを読み込んで、合致したものを標準出力します。 これは which そのものを含む alias において、本オプションを合わせて利用すると便利です。 たとえば以下です。 .br \fBalias which=\'alias | which \-i\'\fP. .\"O ---------------------------------------- .\"O .TP .\"O .B --skip-alias\fR .\"O Ignore option \`--read-alias\', if any. This is useful to .\"O explicity search for normal binaries, while using .\"O the \`--read-alias\' option in an alias or function for which. .TP \fB\-\-skip\-alias\fP \`\-\-read\-alias\' が指定されても無視します。 which に対するエイリアスや関数の中で \`\-\-read\-alias\' オプションを利用している場合であっても、 明示的に通常の実行ファイルを検索する場合に利用できます。 .\"O ---------------------------------------- .\"O .TP .\"O .B --read-functions\fR .\"O Read shell function definitions from stdin, reporting matching .\"O ones on stdout. This is useful in combination with using a shell .\"O function for which itself. For example: .\"O .br .\"O .B .\"O which() { declare -f | which --read-functions $@ } .\"O .br .\"O export -f which\fR .TP \fB\-\-read\-functions\fP 標準入力からシェル関数定義を読み込んで、合致したものを標準出力します。 これはwhich そのものを含むシェル関数において、本オプションを合わせて利用すると便利です。 たとえば以下です。 .br \fBwhich() { declare \-f | which \-\-read\-functions $@ }\fP .br export \-f which .\"O ---------------------------------------- .\"O .TP .\"O .B --skip-functions\fR .\"O Ignore option \`--read-functions\', if any. This is useful to .\"O explicity search for normal binaries, while using .\"O the \`--read-functions\' option in an alias or function for which. .TP \fB\-\-skip\-functions\fP \`\-\-read\-functions\' が指定されても無視します。 which に対するエイリアスや関数の中で \`\-\-read\-functions\' オプションを利用している場合であっても、明示的に通常の実行ファイルを検索する場合に利用できます。 .\"O ---------------------------------------- .\"O .TP .\"O .B --skip-dot\fR .\"O Skip directories in \fBPATH\fR that start with a dot. .TP \fB\-\-skip\-dot\fP \fBPATH\fP 内のディレクトリにうち、ドットで始まるディレクトリは除外します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --skip-tilde\fR .\"O Skip directories in \fBPATH\fR that start with a tilde and .\"O executables which reside in the \fBHOME\fR directory. .TP \fB\-\-skip\-tilde\fP チルダで始まる \fBPATH\fP 内のディレクトリ、および \fBHOME\fP ディレクトリ内に存在する実行ファイルは除外します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --show-dot\fR .\"O If a directory in \fBPATH\fR starts with a dot and a matching .\"O executable was found for that path, then print .\"O "./programname" rather than the full path. .TP \fB\-\-show\-dot\fP \fBPATH\fP 内にドットで始まるディレクトリがあって、合致した実行ファイルがその中に見つかった場合には、フルパスでなく "./programname" と表示します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --show-tilde\fR .\"O Output a tilde when a directory matches the \fBHOME\fR .\"O directory. This option is ignored when which is .\"O invoked as root. .TP \fB\-\-show\-tilde\fP ディレクトリが \fBHOME\fP に合致した場合、チルダを表示します。 このオプションは root ユーザーが実行した際には無視されます。 .\"O ---------------------------------------- .\"O .TP .\"O .B --tty-only\fR .\"O Stop processing options on the right if not on tty. .TP \fB\-\-tty\-only\fP tty 上でない場合、この右側に指定されたオプションの実行を停止します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --version,-v,-V\fR .\"O Print version information on standard output then exit .\"O successfully. .TP \fB\-\-version,\-v,\-V\fP バージョン情報を標準出力して正常終了します。 .\"O ---------------------------------------- .\"O .TP .\"O .B --help\fR .\"O Print usage information on standard output then exit .\"O successfully. .TP \fB\-\-help\fP 利用方法を標準出力して正常終了します。 .\"O ---------------------------------------- .\"O .SH RETURN VALUE .\"O \fBWhich\fR returns the number of failed arguments, or -1 when .\"O no \`programname\' was given. .SH 返り値 \fBwhich\fP は検索に失敗した引数の数を返します。 また \`programname\' が指定されなかった場合は \-1 を返します。 .\"O ---------------------------------------- .\"O .SH EXAMPLE .\"O The recommended way to use this utility is by adding an alias (C shell) .\"O or shell function (Bourne shell) for \fBwhich\fR like the following: .SH 例 このユーティリティーのお薦めの使い方は、 \fBwhich\fP に対するエイリアス (C シェル) やシェル関数 (Bourne シェル) を追加して利用する方法です。 たとえば以下です。 .\"O ---------------------------------------- .\"O .\"O [ba]sh: [ba]sh の場合: .\"O ---------------------------------------- .\"O .\"O .in +5 .\"O .nf .\"O .na .\"O which () .\"O { .\"O (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@ .\"O } .\"O export -f which .\"O .in -5 .\"O .ad .\"O .fi .in +5 .nf .na which () { (alias; declare \-f) | /usr/bin/which \-\-tty\-only \-\-read\-alias \-\-read\-functions \-\-show\-tilde \-\-show\-dot $@ } export \-f which .in -5 .ad .fi .\"O ---------------------------------------- .\"O .\"O [t]csh: [t]csh の場合: .\"O ---------------------------------------- .\"O .\"O .in +5 .\"O .nf .\"O .na .\"O alias which \'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde\' .\"O .in -5 .\"O .ad .\"O .fi .in +5 .nf .na alias which \'alias | /usr/bin/which \-\-tty\-only \-\-read\-alias \-\-show\-dot \-\-show\-tilde\' .in -5 .ad .fi .\"O ---------------------------------------- .\"O .\"O This will print the readable ~/ and ./ when starting which .\"O from your prompt, while still printing the full path when .\"O used from a script: こうすることで、プロンプトから実行した場合には、見やすいように ~/ や ./ を出力します。 スクリプトから利用した場合には、そのままフルパスで出力します。 .\"O ---------------------------------------- .\"O .\"O .in +5 .\"O .nf .\"O .na .\"O > which q2 .\"O ~/bin/q2 .\"O > echo \`which q2\` .\"O /home/carlo/bin/q2 .\"O .in -5 .\"O .ad .\"O .fi .in +5 .nf .na > which q2 ~/bin/q2 > echo \`which q2\` /home/carlo/bin/q2 .in -5 .ad .fi .\"O ---------------------------------------- .\"O ---------------------------------------- .\"O .SH BUGS .\"O The \fBHOME\fR directory is determined by looking for the \fBHOME\fR .\"O environment variable, which aborts when this variable .\"O doesn\'t exist. \fBWhich\fR will consider two equivalent directories .\"O to be different when one of them contains a path .\"O with a symbolic link. .SH バグ \fBHOME\fP ディレクトリは、環境変数 \fBHOME\fP を調べることで決定されますが、この変数が存在しない場合には、その処理がキャンセルされます。\fBwhich\fP は 2 つの同等のディレクトリであっても、その 1 つにシンボリックリンクを使ったパスが含まれている場合に、別のディレクトリと取り扱ってしまいます。 .\"O ---------------------------------------- .\"O .SH AUTHOR .\"O .br .\"O Carlo Wood .SH 著者 .br Carlo Wood .\"O ---------------------------------------- .\"O .SH "SEE ALSO" .\"O \fBbash(1)\fR .SH 関連項目 \fBbash(1)\fP .\"O ----------------------------------------