Try this if you want. Not clever but it works. #! /bin/bash
cd ~ # <replace with your working directory> index=$(cat lastnumber.txt)
index=$(($index + 1)) echo "next number is " . $index echo $index > lastnumber.txt
Nev
I like Nev's solution because a) it's very simple b) it cunningly works around the problem and last but not least c) he didn't tell you that you don't want to do what you want to do. :-)
Steve
To be fair, we were trying to help. It looked like it could be a huge amount of work for not much benefit. (This is disregarding Nev's idea which doesn't look complicated.)
Bev.