RE: Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> > The files are named: sql_10142003.sql.gz
> 

If you change your naming convention a bit it would be easier.

Save the files as sql_20031014.gz - in YYYYMMDD or YYMMDD format instead.

#!/bin/bash

cd /root/junk
backup=($(ls -1 sql_*.gz|LC_COLLATE=C sort -r))
# Show whats in the array
for ((i=0; i<${#backup[*]}; ++i)); do 
   echo "${backup[i]}"
done

# If you know you don't want to touch the first 4 entries
# start a loop at 4 and delete all the remaining files.

for ((i=4; i<${#backup[*]}; ++i)); do 
   echo "Would have erased - ${backup[i]}"
done


Bill Gradwohl
(817) 224-9400 x211
www.ycc.com
SPAMstomper Protected Email


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux