Daily downloads are stored in a directory.
A script has been created which counts how many files reside in this folder.
The part I am struggling with is deleting the oldest file in the directory if the number of files exceeds seven.
How should I proceed?
# If I tared it up would the target exist
tar_file=$FTP_DIR/`basename $newest`.tar
if [-s "$tar_file" ]
then
echo Files Found
else
echo No files
fi
# tar it up
tar -cf tar_file.tar $newest
# how many tar files do I now have
fc=$(ls | wc -l)
echo $fc
# If more than 7 delete the oldest ones
echo $file_count
at the end? – Volker Siegel Sep 14 '14 at 12:42