#!/bin/bash elinks='/usr/local/bin/elinks' function getImage() { echo "checking $1 ..." image=`$elinks -source $1 > out.html && cat out.html | tr ' ' '\n' | grep http://images.4fuckr.com/ | tail -1 | cut -d "\"" -f 2` next=`cat out.html | tr ' ' '\n' | grep 'next' | cut -d "\"" -f 2` echo "$image next: $next" } getImage "$1" while [ $next ] do tmp_image=$image tmp_url="http://www.4fuckr.com$next" getImage "http://www.4fuckr.com$next" done echo "$tmp_image" > last_image echo "$tmp_url" >> last_image