.\" Copyright (c) 1983, 1990, 1993 .\" The Regents of the University of California. 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 the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. .\" .\" @(#)apply.1 8.2 (Berkeley) 4/4/94 .\" %FreeBSD: src/usr.bin/apply/apply.1,v 1.15 2004/07/17 04:04:30 tjr Exp % .\" $FreeBSD$ .\" .Dd July 17, 2004 .Dt APPLY 1 .Os .Sh 名称 .Nm apply .Nd 引数の集合にコマンドを適用する .Sh 書式 .Nm apply .Op Fl a Ar c .Op Fl d .Op Fl # .Ar command argument ... .Sh 解説 .Nm ユーティリティは、 指定されたコマンド .Ar command に、各引数 .Ar argument を順番に与えて実行します。 .Pp .Ar command 内に .Dq Li \&%d の形をした文字列があった場合には (ここで .Sq Li d は 1 から 9 までの数字)、これらは未使用の引数 .Ar argument のうちの .Li d 番目のものと置き換えられます。 このとき .Ar command の実行ごとに最大の .Dq Li d の数だけ引数は捨てられます。 .Pp オプションは以下のものがあります: .Bl -tag -width indent .It Fl # 通常は引数は一つしか渡されません。オプション .Fl # で .Ar command に渡される引数の個数を指定できます。 この数値が 0 のときは、引数なしで .Ar command が引数 .Ar argument につき 1 回、実行されます。 .Pp もし .Ar command 内に .Sq Li \&%d があった場合、 .Fl # オプションは無視されます。 .It Fl a Ar c デフォルトではマジックキャラクタとして .Dq Li % を使っていますが、これは .Fl a オプションで変更ができます。 .It Fl d 実行されるはずだったコマンドを表示しますが、実際には実行しません。 .El .Sh 環境変数 以下の環境変数が .Nm の実行に影響します: .Bl -tag -width SHELL .It Ev SHELL 利用する shell のパス名です。 この変数が定義されていない場合は Bourne シェルが使われます。 .El .Sh 使用例 .Bl -tag -width apply -compact .It Li "apply echo a*" .Xr ls 1 に似た出力になります。 .It Li "apply \-2 cmp a1 b1 a2 b2 a3 b3" `a' のファイルと `b' のファイルを比較します。 .It Li "apply \-0 who 1 2 3 4 5" .Xr who 1 を 5 回実行します。 .It Li "apply \'ln %1 /usr/joe\'" * カレントディレクトリ内の全てのファイルをディレクトリ .Pa /usr/joe にリンクします。 .El .Sh 関連ファイル .Bl -tag -width /bin/sh -compact .It Pa /bin/sh デフォルトの shell です。 .El .Sh 作者 .An Rob Pike .Sh バグ .Ar command 内に shell のメタキャラクタを使用すると、異常な動作をするかもしれません。 複雑なコマンドはシングルクォート .Pq '' で括るのがベストです。 .Pp .Nm ユーティリティは、マルチバイト文字を認識しません。 .Sh 歴史 .Nm コマンドは .Bx 4.2 から登場しました。