Ce script récupère une page au hasard sur xkcd, affiche son titre, puis l’url du comic-strip correspondant.
[code]#!/bin/bash
script xkcd
TODO : update Automatique du nombre de page ($RANDOM%705+1)
dir="/tmp/“
filen=”${dir}xkcd.htm"
RAND=$(($RANDOM%705))
RAND=$(($RAND+1))
wget -O $filen -q http://xkcd.com/${RAND}/
xkcd_count=$(grep "Image URL (for hotlinking/embedding): " $filen | wc -m)
xkcd_count=$(($xkcd_count-6))
xkcd=$(grep "Image URL (for hotlinking/embedding): " $filen | cut -c 43-$xkcd_count)
xkcd=$(grep $xkcd $filen | grep -v “
”)
src="$(echo $xkcd | sed 's/^.* src="(.)" title=.$/\1/'g)“
title=”$(echo $xkcd | sed 's/^.* title="(.)" alt=.$/\1/'g)“
alt=”$(echo $xkcd | sed 's/^.* alt="(.)" .$/\1/'g)"
echo "Strip : “$title
echo $alt” : "$src
exit 0[/code]
Quelle utilité me direz-vous ? Aucune. C’est un premier jet, il fallait bien s’atteler à quelque chose…
Edit : nouvelle version
Edit : Every time you save a kitten, Bach write a parallel fifth

