Created
June 29, 2018 18:16
-
-
Save icasimpan/ea1d8a4bcab042d0326ac72bbbd0bf60 to your computer and use it in GitHub Desktop.
POC shell script for keeping only the last 30 files. Useful for archives.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /var/backup/files | |
let count=1 | |
for each_file in $(ls -1t); do | |
if [ $count -le 30 ]; then | |
echo "[$each_file] - good" | |
let count=$count+1 | |
else | |
echo "[$each_file] - EXPIRED!" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment