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