#!/bin/bash
# This script copies the pgplot files that correspond to zone plots
# (i.e., every fifth plot) into a folder called zone, and then creates
# an animated gif of those plots called zone.gif. A temporary file
# zone_files is created and removed.
# the corresponding pgplot files are posted as pgplot.tar
# first check if the zone directory exists
if [ ! -d zone ]
then
mkdir zone # it doesn't exist, create it
else
# it exists, remove it, then recreate it
rm -r zone # you will need to add -f if rm has been aliased to
# rm -i to avoid being asked about every file
mkdir zone
fi
n=$(ls pglot* | wc -l) # count how many pgplot files we have
> zone_files # create the zone_files file and make sure it's empty
for (( i=5; i < n; i+=5 ))
do
cp "pgplot_$i.png" "zone/plot_$i.png"
echo "zone/plot_$i.png" >> zone_files # append the current plot
# filename to zone_files
done
convert -delay 10 @zone_files zone.gif # create the gif