Googleカスタムサーチを使う方法
Google Custom Search APIの有効化と、サーチエンジンの作成を事前にします。その上で、.bash_profile や .bashrcに以下を記述
export GOOGLE_API_KEY=
export GOOGLE_SEARCH_ENGINE=
imageGetter(){curl "https://www.googleapis.com/customsearch/v1?key=$GOOGLE_API_KEY&cx=$GOOGLE_SEARCH_ENGINE&searchType=image&q=$1" | grep 'jpg\|png' | sed -e "s/\"link\": //g" | sed -e "s/\"//g" | sed -e "s/\,//g" | xargs wget -P $2;}
以下の様に使います。
imageGetter cat tmpdir
catの検索結果がtmpdirに格納されます。