# apply.1

APPLY(1)

APPLY(1)

FreeBSD General Commands Manual

APPLY(1)

## [名称](#__u540D___u79F0_)

`apply` —

将命令应用于一组参数

## [概要](#__u6982___u8981_)

`apply` \[`-a` c] \[`-d`] \[`-#`] command argument ...

## [描述](#__u63CF___u8FF0_)

`apply` 实用程序依次对每个参数 argument 运行 command 命令。

command 中 “`%d`” 形式的字符序列，其中 ‘`d`’ 是从 1 到 9 的数字，被后面的第 `d` 个未使用的 argument 替换。 在这种情况下，每次执行 command 都会丢弃最大位数的参数。

选项如下：

[`-#`](#_)

通常，论点是单独提出的；可选数字 `-#` 指定要传递给 command 的参数数量。 如果数字为零，则对每个 argument 运行一次 command ，不带参数。

如果 command 中出现任何 “`%d`” 序列，则忽略 `-#` 选项。

[`-a`](#a) c

使用 `-a` 选项可以更改使用字符 ‘`%`’ 作为魔术字符。

[`-d`](#d)

显示本应执行但不实际执行的命令。

## [环境](#__u73AF___u5883_)

以下环境变量影响 `apply` 的执行：

[`SHELL`](#SHELL)

要使用的 shell 的路径名。 如果未定义此变量，则使用 Bourne shell。

## [文件](#__u6587___u4EF6_)

/bin/sh

默认 shell

## [实例](#__u5B9E___u4F8B_)

[`apply echo *`](#apply_echo_*)

类似于 ls(1);

[`apply -2 cmp a1 b1 a2 b2 a3 b3`](#apply__-2_cmp_a1_b1_a2_b2_a3_b3)

比较 \`a' 文件和 \`b' 文件；

[`apply -0 who 1 2 3 4 5`](#apply__-0_who_1_2_3_4_5)

运行 who(1) 5 次；

[`apply ´ln %1 /usr/joe´ *`](#apply__'ln__1_/usr/joe_'_*)

将当前目录中的所有文件链接到目录 /usr/joe 。

## [历史](#__u5386___u53F2_)

`apply` 命令出现在 4.2BSD 中。

## [作者](#__u4F5C___u8005_)

Rob Pike

## [缺陷](#__u7F3A___u9677_)

command 中的 shell 元字符可能会产生奇怪的效果；最好将复杂的命令用单引号 ('') 括起来。

`apply` 实用程序无法识别多字节字符。

December 13, 2006

FreeBSD 13.1-RELEASE


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://man.bsdcn.org/man1/apply.1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
