BSD 4_2 development
[unix-history] / usr / man / man1 / apply.1
CommitLineData
11a514e8
C
1.TH APPLY 1 "24 February 1979"
2.SH NAME
3apply \- apply a command to a set of arguments
4.SH SYNOPSIS
5.B apply
6[
7.B \-a\fIc\fP
8] [
9.B \-\fIn\fP
10] command args ...
11.SH DESCRIPTION
12.I Apply
13runs the named
14.I command
15on each
16argument
17.I arg
18in turn.
19Normally arguments are chosen singly; the optional number
20.I n
21specifies the number of arguments to be passed to
22.I command.
23If
24.I n
25is zero,
26.I command
27is run without arguments once for each
28.I arg.
29Character sequences of the form %\fId\fP
30in
31.I command,
32where
33.I d
34is a digit from 1 to 9,
35are replaced by the
36\fId\fP'th following unused
37.I arg.
38If any such sequences occur,
39.I n
40is ignored,
41and the number of arguments passed to
42.I command
43is the maximum value of
44.I d
45in
46.I command.
47The character `%' may be changed by the
48.B \-a
49option.
50.PP
51Examples:
52.RS
53apply echo *
54.RE
55is similar to ls(1);
56.RS
57apply \-2 cmp a1 b1 a2 b2 ...
58.RE
59compares the `a' files to the `b' files;
60.RS
61apply \-0 who 1 2 3 4 5
62.RE
63runs who(1) 5 times; and
64.RS
65apply \(aaln %1 /usr/joe\(aa *
66.RE
67links all files in the current directory to the directory /usr/joe.
68.SH "SEE ALSO"
69sh(1)
70.SH AUTHOR
71Rob Pike
72.SH BUGS
73Shell metacharacters in
74.I command
75may have bizarre effects; it is best to enclose complicated
76commands in single quotes \(aa\ \(aa.
77.sp
78There is no way to pass a literal `%2' if `%' is the
79argument expansion character.