xref: /original-bsd/usr.bin/apply/apply.1 (revision 76210d32)
1.\" Copyright (c) 1983, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\"
5.\"     @(#)apply.1	6.2 (Berkeley) 06/11/90
6.\"
7.Dd
8.Dt APPLY 1
9.Os BSD 4.2
10.Sh NAME
11.Nm apply
12.Nd apply a command to a set of arguments
13.Sh SYNOPSIS
14.Nm apply
15.Op Fl ac
16.Op Fl n
17.Ar command args ...
18.Sh DESCRIPTION
19.Nm Apply
20runs the named
21.Ar command
22on each
23argument
24.Ar arg
25in turn.
26Normally arguments are chosen singly; the optional number
27.Fl n
28specifies the number of arguments to be passed to
29.Ar command .
30If
31.Fl n
32is zero,
33.Ar command
34is run without arguments once for each
35.Ar arg
36Character sequences of the form
37Cx %
38.Ar d
39.Cx
40in
41.Ar command ,
42where
43.Ar d
44is a digit from 1 to 9,
45are replaced by the
46.Ar d\'th
47following unused
48.Ar arg .
49If any such sequences occur,
50.Fl n
51is ignored,
52and the number of arguments passed to
53.Ar command
54is the maximum value of
55.Ar d
56in
57.Ar command .
58The character `%' may be changed by the
59.Fl a
60option.
61.SH ENVIRONMENT
62.Nm apply
63checks the environment variable
64.Ev SHELL
65to find out which shell to use.
66.Sh EXAMPLES
67.Ds
68.Tw apply \-2 cmp a1 b1 a2 b2 ...
69.Tp Li apply echo a*
70is similar to ls(1);
71.Tp Li apply \-2 cmp a1 b1 a2 b2 ...
72compares the `a' files to the `b' files;
73.Tp Li apply \-0 who 1 2 3 4 5
74runs who(1) 5 times; and
75.Tp Li apply \(aaln %1 /usr/joe\(aa *
76links all files in the current directory to the directory
77.Pa /usr/joe .
78.Tp
79.De
80.Sh SEE ALSO
81.Xr sh 1
82.Sh HISTORY
83.Nm Apply
84appeared in 4.2BSD.
85.Sh AUTHOR
86Rob Pike
87.Sh BUGS
88Shell metacharacters in
89.Ar command
90may have bizarre effects; it is best to enclose complicated
91commands in single quotes \(aa\ \(aa.
92.Pp
93There is no way to pass a literal `%2' if `%' is the
94argument expansion character.
95