Name
apply
Synopsis
apply [options
]command arguments
Allows you to run a given command multiple times, each time with a
different argument. By default, apply
pairs and
runs command followed by each argument listed in
arguments. To place the argument elsewhere in
command, mark that location in
command with
%
n, where
n is the
n
th unused item
listed in arguments (see examples).
Options
-
-a
character
Use character instead of
%
.-
-
number
Instead of pairing arguments one at a time with command, use them number at a time with command. If number is 0, none of the arguments will be used with command, but command will still run once for each item listed in arguments. If command contains
%
n, number is ignored.
Examples
Ping three different hosts, sending three packets to each:
apply 'ping -c3' host1.com host2.com host3.com
Ping three different hosts, sending a different number of packets to each:
apply -2 'ping -c' 3 host1.com 4 host2.com 5 host3.com
Ping three different hosts, and write output to file pinglog:
apply 'ping -c3 %1 >> pinglog' host1.com host2.comhost3.com
Get Mac OS X in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.