How To: Screencapture from Terminal in OS X

MacDevCenter.com: Screenshot Hacks for Mac OS X

The Terminal application comes with a command-line screen capture utility known as screencapture.

This utility provides capabilities similar to those of Grab. To use it, invoke the Terminal window and type screencapture to see the various options supported:

screencapture
screencapture: illegal usage, file required if not going to clipboard
usage: screencapture [-icmwsWx] [file] [cursor]
-i capture screen interactively, by selection or window
control key – causes screen shot to go to clipboard
space key – toggle between mouse selection and
window selection modes
escape key – cancels interactive screen shot
-c force screen capture to go to the clipboard
-m only capture the main monitor, undefined if -i is set
-w only allow window selection mode
-s only allow mouse selection mode
-W start interaction in window selection mode
-x do not play sounds
file where to save the screen capture

To capture the entire screen, type:

screencapture imagefilename.pdf

The image will be saved as imagefilename.pdf.