2.11BSD/man/cat1/apply.0
APPLY(1) UNIX Programmer's Manual APPLY(1)
NAME
apply - apply a command to a set of arguments
SYNOPSIS
apply [ -a_c ] [ -_n ] command args ...
DESCRIPTION
_A_p_p_l_y runs the named _c_o_m_m_a_n_d on each argument _a_r_g in turn.
Normally arguments are chosen singly; the optional number _n
specifies the number of arguments to be passed to _c_o_m_m_a_n_d.
If _n is zero, _c_o_m_m_a_n_d is run without arguments once for each
_a_r_g. Character sequences of the form %_d in _c_o_m_m_a_n_d, where _d
is a digit from 1 to 9, are replaced by the _d'th following
unused _a_r_g. If any such sequences occur, _n is ignored, and
the number of arguments passed to _c_o_m_m_a_n_d is the maximum
value of _d in _c_o_m_m_a_n_d. The character `%' may be changed by
the -a option.
Examples:
apply echo *
is similar to ls(1);
apply -2 cmp a1 b1 a2 b2 ...
compares the `a' files to the `b' files;
apply -0 who 1 2 3 4 5
runs who(1) 5 times; and
apply 'ln %1 /usr/joe' *
links all files in the current directory to the directory
/usr/joe.
SEE ALSO
sh(1)
AUTHOR
Rob Pike
BUGS
Shell metacharacters in _c_o_m_m_a_n_d may have bizarre effects; it
is best to enclose complicated commands in single quotes
' '.
There is no way to pass a literal `%2' if `%' is the argu-
ment expansion character.
Printed 11/26/99 April 29, 1985 1