Created
July 20, 2023 14:01
-
-
Save rafaelmaeuer/3ccf2f313b42ab089f06067ae040fe36 to your computer and use it in GitHub Desktop.
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
# The script receives the limit as an argument. | |
limit=$1 | |
number_of_files=$(ls ./files | wc -l) | |
if [ $number_of_files -gt $limit ] | |
then | |
# There are more files than the limit | |
# So we need to remove the older ones. | |
cd files | |
ls -t | tail --lines=+$(expr $limit + 1) | xargs -d '\n' rm | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment