Hi,
So, you want to delete the oldest file on the 6th time it makes a tarball right? Simple enough:
[root@linux mnt]# ls -alrt
total 20
-rw-r--r-- 1 root root 0 Mar 3 2004 file1
-rw-r--r-- 1 root root 0 Apr 3 2004 file2
-rw-r--r-- 1 root root 0 May 3 2004 file3
-rw-r--r-- 1 root root 0 Jun 3 2004 file4
-rw-r--r-- 1 root root 0 Jul 3 2004 file5
drwxr-xr-x 2 root root 4096 Nov 19 2004 floppy
drwxr-xr-x 2 root root 4096 Nov 19 2004 cdrom
drwxr-xr-x 22 root root 4096 Mar 8 10:07 ..
drwxr-xr-x 2 root root 4096 Apr 17 12:23 test
-rw-r--r-- 1 root root 0 May 10 16:21 file6
drwxr-xr-x 5 root root 4096 May 10 16:22 .
The files I made are "file[123456]" as you can see and I changed the time to reflect which one is older than the other. Once file6 is created, you can just run this to delete file1 (which is the oldest file)
Code:
rm -f `ls -alrt | head -2 | grep -v total | awk '{print $9}'`
Of course, you can make this a bit more prettier and have check conditions and whatnot. This is just a head start for you
. Let us know if you still need more help in creating your bash script.
-twantrd