回数をカウントして、使用制限をかけたいことなどがありますが、そんなときは「数をカウントするシェルスクリプト」を応用します。
#!/bin/sh
current=0;
if [ -f .count ]; then
current=`cat .count`
if [ ${current} -gt 2 ]; then
echo "over"
exit
fi
fi
cnt=`expr ${current} + 1`
echo ${cnt} | /usr/bin/tee .count
current=0;
if [ -f .count ]; then
current=`cat .count`
if [ ${current} -gt 2 ]; then
echo "over"
exit
fi
fi
cnt=`expr ${current} + 1`
echo ${cnt} | /usr/bin/tee .count
なんてことのないbashプログラムですが、いろいろな場面で役に立つはずです。