Skip to content

Instantly share code, notes, and snippets.

@aleksandar-babic
Created July 2, 2018 07:40
Show Gist options
  • Save aleksandar-babic/5cca28c779fef60808d51308547760cf to your computer and use it in GitHub Desktop.
Save aleksandar-babic/5cca28c779fef60808d51308547760cf to your computer and use it in GitHub Desktop.
Bash script to delete old js bundles
#!/usr/bin/env bash
if [ $# -ne 1 ]
then
echo "Usage: ./wipe_old_builds.sh /path/to/builds/directory"
exit 1
fi
cd $1
if [ $? -ne 0 ]
then
echo "Failed to CD into $1, exiting.."
exit 1
fi
echo "Deleting old builds from $1"
ls -t *.js* | tail -n +7 | xargs rm --
if [ $? -eq 0 ]
then
echo "Old builds have been deleted."
exit 0
fi
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment