Skip to content

Instantly share code, notes, and snippets.

@7rin0
Last active June 28, 2018 15:19
Show Gist options
  • Save 7rin0/4d05e35ced811f4998d2447b4844d84b to your computer and use it in GitHub Desktop.
Save 7rin0/4d05e35ced811f4998d2447b4844d84b to your computer and use it in GitHub Desktop.
Shell > Keep the last 3 revisions
# oneline
RELEASE_NB=$(ls -tdr -- */ | cut -d'/' -f1 | wc -w) && RELEASE_NB_DIFF=$(echo $RELEASE_NB-3 | bc) && if test $RELEASE_NB > 3 ; then rm -rf $(ls -tdr -- */ | head -$RELEASE_NB_DIFF | cut -d'/' -f1) ; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment