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. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)apply.1 8.2 (Berkeley) 4/4/94 29.\" $FreeBSD$ 30.\" 31.Dd January 28, 2022 32.Dt APPLY 1 33.Os 34.Sh NAME 35.Nm apply 36.Nd apply a command to a set of arguments 37.Sh SYNOPSIS 38.Nm 39.Op Fl a Ar c 40.Op Fl d 41.Op Cm - Ns Ar # 42.Ar command argument ... 43.Sh DESCRIPTION 44The 45.Nm 46utility runs the named 47.Ar command 48on each 49argument 50.Ar argument 51in turn. 52.Pp 53Character sequences of the form 54.Dq Li \&%d 55in 56.Ar command , 57where 58.Sq Li 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 indent 69.It Cm - Ns Ar # 70Normally arguments are taken singly; the optional number 71.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 # 85option is ignored. 86.It Fl a Ar c 87The use of the character 88.Sq Li % 89as a magic character may be changed with the 90.Fl a 91option. 92.It Fl d 93Display the commands that would have been executed, but do not actually 94execute them. 95.El 96.Sh ENVIRONMENT 97The following environment variable affects the execution of 98.Nm : 99.Bl -tag -width SHELL 100.It Ev SHELL 101Pathname of shell to use. 102If this variable is not defined, the Bourne shell is used. 103.El 104.Sh FILES 105.Bl -tag -width /bin/sh -compact 106.It Pa /bin/sh 107default shell 108.El 109.Sh EXAMPLES 110.Bl -tag -width apply -compact 111.It Li "apply echo *" 112is similar to 113.Xr ls 1 ; 114.It Li "apply \-2 cmp a1 b1 a2 b2 a3 b3" 115compares the `a' files to the `b' files; 116.It Li "apply \-0 who 1 2 3 4 5" 117runs 118.Xr who 1 1195 times; and 120.It Li "apply \'ln %1 /usr/joe\'" * 121links all files in the current directory to the directory 122.Pa /usr/joe . 123.El 124.Sh HISTORY 125The 126.Nm 127command appeared in 128.Bx 4.2 . 129.Sh AUTHORS 130.An Rob Pike 131.Sh BUGS 132Shell metacharacters in 133.Ar command 134may have bizarre effects; it is best to enclose complicated 135commands in single quotes 136.Pq '' . 137.Pp 138The 139.Nm 140utility does not recognize multibyte characters. 141