O seguinte usa data.csv
como um link para o arquivo solicitado para manter o status entre as iterações.
# check to see if an argument is given
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit
fi
# check if ran before if so move that to processed/ directory
if [ -h "data.csv" ]; then
prev='readlink data.csv'
echo "Found previous run $prev"
rm -f data.csv # remove link
mv -f $prev processed/ # move previous file to processed directory
echo "Moved to processed/$prev"
fi
# check to see if file exists
if [ -e data$1.csv ]; then
ln -s data$1.csv data.csv # link data.csv to the requested file
echo "Linked data.csv -> data$1.csv"
else
echo "No such file data$1.csv"
fi