Created
July 27, 2016 08:41
-
-
Save FedericoPonzi/cd7195f9e4a30c23ed1f8e0a52affc54 to your computer and use it in GitHub Desktop.
A sample log rotate script, will keep the 5 newest files in this folder
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 | |
# 1. ls this directory | |
# 2. Remove from the list the 5 most recent files | |
# 3. Remove from the directory the remaining files. | |
ls | grep -v "$(ls -t | head -n 5)" | xargs -n 1 rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment