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.1 (Berkeley) 06/06/93 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 n 18.Ar command args ... 19.Sh DESCRIPTION 20.Nm Apply 21runs the named 22.Ar command 23on each 24argument 25.Ar arg 26in turn. 27.Pp 28Options available are: 29.Bl -tag -width "-ac" 30.It Fl Ns Ar n 31Normally arguments are chosen singly; the optional number 32.Fl n 33specifies the number of arguments to be passed to 34.Ar command . 35If 36.Fl n 37is zero, 38.Ar command 39is run without arguments once for each 40.Ar arg . 41Character sequences of the form 42.Pf \&% Ar d 43in 44.Ar command , 45where 46.Ar d 47is a digit from 1 to 9, 48are replaced by the 49.Ar d Ns \'th 50following unused 51.Ar arg . 52If any such sequences occur, 53.Fl n 54is ignored, 55and the number of arguments passed to 56.Ar command 57is the maximum value of 58.Ar d 59in 60.Ar command . 61.It Fl a Ns Ar c 62The character 63.Ql % 64may be changed by the 65.Fl a 66option. 67.El 68.Sh ENVIRONMENT 69The following environment variable is used by 70.Nm apply : 71.Bl -tag -width SHELL 72.It Ev SHELL 73Pathname of shell to use. If this option is not defined, 74a default shell is used. 75.El 76.Sh EXAMPLES 77.Bl -tag -width apply -compact 78.It Li "apply echo a*" 79is similar to ls(1); 80.It Li "apply \-2 cmp a1 b1 a2 b2 ..." 81compares the `a' files to the `b' files; 82.It Li "apply \-0 who 1 2 3 4 5" 83runs who(1) 5 times; and 84.It Li "apply \'ln %1 /usr/joe\'" * 85links all files in the current directory to the directory 86.Pa /usr/joe . 87.El 88.Sh SEE ALSO 89.Xr sh 1 90.Sh AUTHOR 91Rob Pike 92.Sh BUGS 93Shell metacharacters in 94.Ar command 95may have bizarre effects; it is best to enclose complicated 96commands in single quotes 97.Pq Sq . 98.Pp 99There is no way to pass a literal 100.Ql %2 101if 102.Ql % 103is the 104argument expansion character. 105.Sh HISTORY 106The 107.Nm 108command appeared in 109.Bx 4.2 . 110