Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use macOS’s built-in screencapture utility. For a full-screen PNG, run screencapture "$HOME/Desktop/shot.png". Add flags when you need an interactive selection, a window, a monitor, a fixed rectangle, a delay, another image format, the clipboard, the pointer, or silent operation.

What screencapture does

screencapture is a macOS command-line utility for still images. You run it from Terminal or a Bash script, specify capture options, and provide a destination path. PNG is the documented default. The same utility also documents video-recording switches, but this guide focuses on still screenshots.

These commands must run on a Mac with a graphical login session. A shell connected to a headless Mac, SSH session without a usable display, or automation running without screen-capture permission can fail even when the command syntax is correct.

The basic Bash command

Open Terminal and run:

screencapture "$HOME/Desktop/shot.png"

The command captures the screen and writes shot.png to your Desktop. Quoting the path protects spaces and special characters. You can use an absolute path, a path relative to the current directory, or a shell variable:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
out="$HOME/Desktop/capture-$(date +%Y-%m-%d-%H%M%S).png"
screencapture "$out"
printf 'Saved %sn' "$out"

If the destination already exists, do not assume that every macOS release will prompt before replacing it. Generate unique names or check first:

out="$HOME/Desktop/shot.png"
if [[ -e "$out" ]]; then
  printf 'Refusing to overwrite %sn' "$out" >&2
  exit 1
fi
screencapture "$out"

Choose the capture target

Entire screen

screencapture "$HOME/Desktop/full-screen.png"

This is the simplest non-interactive form. On a multi-display Mac, behavior can include more than one display depending on the system’s display arrangement and the macOS version. Test on the Mac where the script will run.

Main monitor only

screencapture -m -x "$HOME/Desktop/main-monitor.png"

-m restricts a non-interactive capture to the main monitor. -x suppresses the capture sound. Display numbering and “main” monitor selection come from macOS display settings, so verify the result when a script is deployed to different hardware.

Interactive region or window

screencapture -i "$HOME/Desktop/selection.png"

-i starts an interactive capture. Use the pointer to select a region or, where supported by the current macOS behavior, a window. This is useful when the rectangle cannot be known in advance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Window-oriented capture

screencapture -w "$HOME/Desktop/window.png"

The -w and -W modes select window-oriented capture behavior. Because window focus and the available window list can vary by macOS release, try both the documented mode appropriate to your workflow and an interactive -i capture when you need a visible choice.

Fixed rectangle

screencapture -R 100,100,800,600 "$HOME/Desktop/rectangle.png"

-R takes four comma-separated values: x,y,width,height. In this example, capture begins at coordinate 100,100 and is 800 pixels wide by 600 pixels high. Coordinates depend on the display layout, scaling, and which display is treated as the coordinate origin. Confirm them visually before putting them into a long-running script.

Control the output

Image format

screencapture -t jpg "$HOME/Desktop/shot.jpg"
screencapture -t png "$HOME/Desktop/shot.png"
screencapture -t tiff "$HOME/Desktop/shot.tiff"
screencapture -t pdf "$HOME/Desktop/shot.pdf"

The manual lists png, pdf, jpg, and tiff. Use PNG when you need lossless text and interface details, JPEG when a smaller photographic file is more important, TIFF for workflows that require it, and PDF when the receiving application expects a document. Keep the file extension consistent with the selected type.

Delay the capture

screencapture -T 5 "$HOME/Desktop/delayed.png"

-T delays the capture by the specified number of seconds. A delay gives you time to open a menu, arrange a window, or move the pointer before the image is taken.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Copy to the clipboard

screencapture -c

-c places the capture on the clipboard instead of writing a file. Paste it into an image editor, document, chat window, or other application. Since there is no output path to inspect, a script should check the command’s exit status and optionally notify the user.

Pointer and sound

screencapture -C "$HOME/Desktop/with-cursor.png"
screencapture -x "$HOME/Desktop/silent.png"
screencapture -C -x "$HOME/Desktop/cursor-silent.png"

-C includes the cursor. -x suppresses the capture sound. These switches can be combined with target and format options.

Useful Bash scripts

Timestamped repeated captures

This loop takes one screenshot every 10 seconds and stops with Ctrl-C:

#!/usr/bin/env bash
set -u

out_dir="$HOME/Desktop/screen-captures"
mkdir -p "$out_dir"

while true; do
  name="shot-$(date +%Y-%m-%d-%H%M%S).png"
  path="$out_dir/$name"
  if screencapture -x "$path"; then
    printf 'Saved %sn' "$path"
  else
    printf 'Capture failedn' >&2
    exit 1
  fi
  sleep 10
done

Seconds are only precise to the naming scheme shown. If two captures occur within the same second, add nanoseconds where your macOS shell supports them or maintain a counter to prevent a collision.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture a known rectangle repeatedly

#!/usr/bin/env bash
set -euo pipefail

out_dir="$HOME/Desktop/rectangle-captures"
mkdir -p "$out_dir"

for n in {1..12}; do
  path="$out_dir/rect-$n.png"
  screencapture -R 100,100,800,600 -x "$path"
  sleep 5
done

Use a fixed rectangle only when the application and display geometry are stable. A moved window, changed scaling setting, or different monitor arrangement can make the same coordinates capture the wrong content.

Reusable command-line wrapper

#!/usr/bin/env bash
set -euo pipefail

usage() {
  printf 'Usage: %s OUTPUTn' "$0" >&2
  exit 2
}

[[ $# -eq 1 ]] || usage
output=$1
mkdir -p "$(dirname "$output")"
screencapture -x "$output"
printf '%sn' "$output"

Save it as take-shot.sh, make it executable with chmod +x take-shot.sh, and call ./take-shot.sh "$HOME/Desktop/run.png". set -euo pipefail makes failures visible instead of silently continuing.

Automate safely

  • Use absolute paths. Scheduled jobs may start in a different working directory.
  • Create the destination directory. mkdir -p avoids a failure when the folder is new.
  • Check the exit status. A nonzero result means the file may not represent a successful capture.
  • Use unique names. Timestamps or counters prevent accidental replacement.
  • Keep the Mac awake and logged in. Lock screens, sleep, and unavailable graphical sessions can prevent the intended image.
  • Grant permission. In System Settings, review Privacy & Security permissions for the terminal or automation host that is attempting to capture the screen.
  • Validate the artifact. Test that the file exists and is non-empty before uploading or processing it.
path="$HOME/Desktop/checked.png"
if ! screencapture -x "$path"; then
  printf 'screencapture returned an errorn' >&2
  exit 1
fi
if [[ ! -s "$path" ]]; then
  printf 'Capture file is missing or empty: %sn' "$path" >&2
  exit 1
fi

Which command should you use?

Need Command pattern Important options
Whole display screencapture file.png Default PNG
Main monitor screencapture -m file.png Non-interactive main-monitor capture
Choose an area screencapture -i file.png Interactive selection
Choose a window screencapture -w file.png Window-oriented mode; behavior can vary
Known coordinates screencapture -R x,y,w,h file.png Fixed rectangle
Wait first screencapture -T 5 file.png Five-second delay
Clipboard screencapture -c No file is created
Silent capture screencapture -x file.png Suppresses sound
Include pointer screencapture -C file.png Cursor appears in the image

Troubleshooting

“command not found: screencapture”

You are probably not running macOS, or the system path is unusual. screencapture is a macOS utility and is not a portable Linux or Windows Bash command. Confirm the operating system and try /usr/sbin/screencapture if your PATH does not include the standard system directories.

The command returns an error or produces no useful image

Check that a user is logged in, the display is available, the destination directory exists, and the terminal or automation process has screen-recording permission. Run a simple interactive test first, then add script complexity one option at a time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The rectangle is wrong

Re-measure x,y,width,height on the target Mac. Multiple displays, Retina scaling, display arrangement, and a changed resolution can alter effective coordinates. A fixed rectangle is not a semantic reference to a window; it is just a coordinate box.

The file is saved in an unexpected format

Set the type explicitly with -t and use a matching extension. For example, screencapture -t jpg "$HOME/Desktop/shot.jpg". Do not rely on an extension alone to select the encoding.

The script overwrites or misses files

Use a unique timestamp or counter, quote every path, create the directory, and test [[ -s "$path" ]] after the command. A loop should also stop or log clearly when a capture fails.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For web-page screenshots rather than the Mac’s physical display, ScreenshotNeo provides a website screenshot API and MCP server. A single request returns PNG, JPEG, WebP, or PDF. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—work with Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);

See the ScreenshotNeo documentation for the 63 capture options, including full-page and element capture, device presets, Retina scale, custom CSS and JavaScript, waits, request blocking, headers and cookies, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, bulk capture, and usage information. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

macOS keyboard alternatives

For an occasional manual capture, Apple’s shortcuts may be faster: Shift-Command-3 captures the full screen, while Shift-Command-4 lets you select an area. The normal screenshot file format is PNG. Use screencapture when you need repeatability, scripting, a fixed rectangle, a delay, clipboard output, or explicit format and sound controls.

Frequently Asked Questions

Can I run screencapture from a Linux Bash shell?

No. screencapture is a macOS utility. Linux and other systems require their own screenshot tools.

Does screencapture capture a website directly from its URL?

No. It captures the Mac display or a display region/window. Use a browser automation workflow or a web screenshot API for URL-based captures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I stop a repeated screenshot loop?

Press Ctrl-C in the Terminal running the foreground loop, or terminate the controlling process if it was launched by another scheduler.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.