#!/bin/bash
# Purge OS filesystem cache
# Give this script appropriate privileges:
#   macOS: sudo chmod +s purge_cache.sh (or add to sudoers)
#   Linux: sudo chmod +s purge_cache.sh (or add to sudoers)

case "$(uname)" in
    Darwin)
        purge
        ;;
    Linux)
        sync
        echo 3 > /proc/sys/vm/drop_caches
        ;;
    *)
        echo "Unsupported OS" >&2
        exit 1
        ;;
esac
