Shell Script to Take a Screenshot of Android Devices
Here is a Shell Script to take a screenshot of Android devices. You need setup adb
before running this script. The script temporary saves the screenshot to device’s local /sdcard/
, then move the file to current directory. The format of image is PNG, and the file name is {timestamp}.png
.
filename=`date "+%s"`
adb shell screencap -p /sdcard/${filename}.png
adb pull /sdcard/${filename}.png
adb shell rm /sdcard/${filename}.png
The adb
option of -p
at the second line is for taking a screen shot with PNG format, but the document does not put the option, so maybe it is not required :)
Save the script asscreenshot.sh
and run.
% sh screenshot.sh
Environment
- macOS Big Sur 11.4
- zsh 5.8
References
- Android Debug Bridge (adb) | Android Developers (Last access: 2021/06/15)
About me 😎

茨城県つくば市在住のソフトウェアエンジニアです。専門領域はAndroidアプリ開発で、特にアーキテクチャに興味があります。某社でAndroidアプリ開発のテックリードをしています。
Jetpack ComposeによるAndroid MVVMアーキテクチャ入門の著者です。
👉 もっと詳しく
Writing 📝
Android MVVMアーキテクチャ入門
Androidアプリ開発の初学者に向けた、MVVM(Model-View-ViewModel)アーキテクチャの入門書を書きました。初学者の方を確実にネクストレベルに引き上げる技術書です。
👉 もっと詳しく