Take a screen capture from the command line
Taking screenshots from the command line is made easy, thanks to a utility included in Mac OS X called screencapture. Here’s how to use it:
screencapture test.jpg The screen capture will then appear in the directory that the command was executed.
There are more advanced features to the screencapture utility though, here’s a few examples.
Open the screencapture in Preview immediately after being taken:
screencapture -P test.jpg
Take screenshots silently, with no sound playing:
screencapture -x silentscreenshot.jpg
Delay when the screenshot is taken by using the -T flag followed by seconds:
screencapture -T 3 delayedpic.jpg
Specify a file type for the screenshot (most major image formats are supported: JPG, PNG, PDF, etc):
screencapture -t pdf pdfshot.pdf
Like most other terminal commands, you can combine the flags together and do all of the above at once:
screencapture -xt pdf -T 4 pic.jpg
To see a full list of screencapture options, use the -h flag:
These instructions appeared on our screen capture in Mac OS article.