Skip to Content
Mac OS X in a Nutshell
book

Mac OS X in a Nutshell

by Jason McIntosh, Chuck Toporek, Chris Stone
January 2003
Intermediate to advanced
832 pages
32h 40m
English
O'Reilly Media, Inc.
Content preview from Mac OS X in a Nutshell

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.comExampleshost3.com

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mac OS X Internals: A Systems Approach

Mac OS X Internals: A Systems Approach

Amit Singh
C++ In a Nutshell

C++ In a Nutshell

Ray Lischner
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar
Optimized C++

Optimized C++

Kurt Guntheroth

Publisher Resources

ISBN: 0596003706Supplemental ContentCatalog PageErrata