BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / apply.0
APPLY(1) UNIX Programmer's Manual APPLY(1)
N\bNA\bAM\bME\bE
apply - apply a command to a set of arguments
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
a\bap\bpp\bpl\bly\by [ -\b-a\ba_\bc ] [ -\b-_\bn ] command args ...
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
_\bA_\bp_\bp_\bl_\by runs the named _\bc_\bo_\bm_\bm_\ba_\bn_\bd on each argument _\ba_\br_\bg in turn.
Normally arguments are chosen singly; the optional number _\bn
specifies the number of arguments to be passed to _\bc_\bo_\bm_\bm_\ba_\bn_\bd.
If _\bn is zero, _\bc_\bo_\bm_\bm_\ba_\bn_\bd is run without arguments once for each
_\ba_\br_\bg. Character sequences of the form %_\bd in _\bc_\bo_\bm_\bm_\ba_\bn_\bd, where _\bd
is a digit from 1 to 9, are replaced by the _\bd'th following
unused _\ba_\br_\bg. If any such sequences occur, _\bn is ignored, and
the number of arguments passed to _\bc_\bo_\bm_\bm_\ba_\bn_\bd is the maximum
value of _\bd in _\bc_\bo_\bm_\bm_\ba_\bn_\bd. The character `%' may be changed by
the -\b-a\ba 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.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
sh(1)
A\bAU\bUT\bTH\bHO\bOR\bR
Rob Pike
B\bBU\bUG\bGS\bS
Shell metacharacters in _\bc_\bo_\bm_\bm_\ba_\bn_\bd 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 7/9/88 April 29, 1985 1