xref: /netbsd-src/usr.bin/apply/apply.1 (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1.\"	$NetBSD: apply.1,v 1.12 2006/12/24 10:07:18 wiz Exp $
2.\"
3.\" Copyright (c) 1983, 1990, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)apply.1	8.2 (Berkeley) 4/4/94
31.\"
32.Dd April 4, 1994
33.Dt APPLY 1
34.Os
35.Sh NAME
36.Nm apply
37.Nd apply a command to a set of arguments
38.Sh SYNOPSIS
39.Nm
40.Op Fl a Ns Ar c
41.Op Fl Ns Ar #
42.Ar command argument ...
43.Sh DESCRIPTION
44.Nm
45runs the named
46.Ar command
47on each
48argument
49.Ar argument
50in turn.
51.Pp
52Character sequences of the form
53.Dq Li \&%d
54in
55.Ar command ,
56where
57.Dq Li d
58is a digit from 1 to 9, are replaced by the
59.Li d Ns \'th
60following unused
61.Ar argument .
62In this case, the largest digit number of arguments are discarded for
63each execution of
64.Ar command .
65.Pp
66The options are as follows:
67.Bl -tag -width "-ac"
68.It Fl Ns Ar #
69Normally arguments are taken singly; the optional number
70.Fl #
71specifies the number of arguments to be passed to
72.Ar command .
73If the number is zero,
74.Ar command
75is run, without arguments, once for each
76.Ar argument .
77.Pp
78If any sequences of
79.Dq Li \&%d
80occur in command, the
81.Fl #
82option is ignored.
83.It Fl a Ns Ar c
84The use of the character
85.Dq Li %
86as a magic character may be changed with the
87.Fl a
88option.
89.El
90.Sh ENVIRONMENT
91The following environment variable affects the execution of
92.Nm :
93.Bl -tag -width SHELL
94.It Ev SHELL
95Pathname of shell to use.
96If this variable is not defined, the Bourne shell is used.
97.El
98.Sh FILES
99.Bl -tag -width /bin/sh -compact
100.It Pa /bin/sh
101Default shell
102.El
103.Sh EXAMPLES
104.Bl -tag -width apply -compact
105.It Li "apply echo *"
106is similar to
107.Xr ls 1 ;
108.It Li "apply \-2 cmp a1 b1 a2 b2 a3 b3"
109compares the `a' files to the `b' files;
110.It Li "apply \-0 who 1 2 3 4 5"
111runs
112.Xr who 1
1135 times; and
114.It Li "apply \'ln %1 /usr/joe\'" *
115links all files in the current directory to the directory
116.Pa /usr/joe .
117.El
118.Sh HISTORY
119The
120.Nm
121command appeared in
122.Bx 4.2 .
123.Sh AUTHORS
124.An Rob Pike
125.Sh BUGS
126Shell metacharacters in
127.Ar command
128may have bizarre effects; it is best to enclose complicated
129commands in single quotes
130.Pq '' .
131