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