xref: /original-bsd/usr.bin/apply/apply.1 (revision 7e5c8007)
1.\" Copyright (c) 1983, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)apply.1	8.2 (Berkeley) 04/04/94
7.\"
8.Dd
9.Dt APPLY 1
10.Os BSD 4.2
11.Sh NAME
12.Nm apply
13.Nd apply a command to a set of arguments
14.Sh SYNOPSIS
15.Nm apply
16.Op Fl a Ns Ar c
17.Op Fl Ns Ar #
18.Ar command argument ...
19.Sh DESCRIPTION
20.Nm Apply
21runs the named
22.Ar command
23on each
24argument
25.Ar argument
26in turn.
27.Pp
28Character sequences of the form
29.Dq Li \&%d
30in
31.Ar command ,
32where
33.Dq Li d
34is a digit from 1 to 9, are replaced by the
35.Li d Ns \'th
36following unused
37.Ar argument .
38In this case, the largest digit number of arguments are discarded for
39each execution of
40.Ar command .
41.Pp
42The options are as follows:
43.Bl -tag -width "-ac"
44.It Fl Ns Ar #
45Normally arguments are taken singly; the optional number
46.Fl #
47specifies the number of arguments to be passed to
48.Ar command .
49If the number is zero,
50.Ar command
51is run, without arguments, once for each
52.Ar argument .
53.Pp
54If any sequences of
55.Dq Li \&%d
56occur in command, the
57.Fl n
58option is ignored.
59.It Fl a Ns Ar c
60The use of the character
61.Dq Li %
62as a magic character may be changed with the
63.Fl a
64option.
65.El
66.Sh ENVIRONMENT VARIABLES
67The following environment variable affects the execution of
68.Nm apply :
69.Bl -tag -width SHELL
70.It Ev SHELL
71Pathname of shell to use.
72If this variable is not defined, the Bourne shell is used.
73.El
74.Sh EXAMPLES
75.Bl -tag -width apply -compact
76.It Li "apply echo a*"
77is similar to ls(1);
78.It Li "apply \-2 cmp a1 b1 a2 b2 a3 b3"
79compares the `a' files to the `b' files;
80.It Li "apply \-0 who 1 2 3 4 5"
81runs who(1) 5 times; and
82.It Li "apply \'ln %1 /usr/joe\'" *
83links all files in the current directory to the directory
84.Pa /usr/joe .
85.El
86.Sh Files
87.Bl -tag -width /bin/sh -compact
88.It Pa /bin/sh
89Default shell
90.El
91.Sh AUTHOR
92Rob Pike
93.Sh BUGS
94Shell metacharacters in
95.Ar command
96may have bizarre effects; it is best to enclose complicated
97commands in single quotes
98.Pq Sq .
99.Sh HISTORY
100The
101.Nm
102command appeared in
103.Bx 4.2 .
104