Android Task Screenshot with Command

From: http://linuxtoy.org/archives/one-line-to-capture-screenshot-on-android.html

General you can press both the volume(-) and power on button to take a screenshot,but for a developer you can use a command to do it in a awesome way.

On Linux:

adb shell screencap -p | sed 's/\r$//' > screen.png

On OS X:

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

android_screenshot script

#!/bin/sh

file=`date +%y%H%M%S`
if [ ${#} == 1 ];then
   file=${1}
fi

echo "Take android screenshot as ${file}.png"

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ${file}.png