Compare commits
No commits in common. "979488b062c0f638a84bca6ddaed393579ec6299" and "cca89fceebb9ccdfe5eed6a4ae11e9150a2860cb" have entirely different histories.
979488b062
...
cca89fceeb
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
print_and_run() {
|
||||
local cmd="$*"
|
||||
printf '➜ %s\n' "$cmd"
|
||||
# pipefail applies to the subshell; change/remove if not desired
|
||||
bash -o pipefail -c "$cmd"
|
||||
}
|
||||
|
||||
|
||||
SHRUNK="/opt/vm_drive/shrunk"
|
||||
LINKS="/opt/vm_drive/*.qcow2"
|
||||
ACTION="echo Would remove" # default: dry-run
|
||||
|
||||
DRYRUN=0
|
||||
if [[ "$1" == "--dry-run" ]]; then
|
||||
DRYRUN=1
|
||||
shift
|
||||
fi
|
||||
|
||||
find "$SHRUNK" -maxdepth 1 -type f -printf '%f\n' \
|
||||
| grep -vxFf <(readlink -f $LINKS | xargs -n1 basename) \
|
||||
| while read -r f; do
|
||||
if (( DRYRUN )); then
|
||||
echo "Would remove: $SHRUNK/$f"
|
||||
else
|
||||
echo "Removing: $SHRUNK/$f"
|
||||
rm -v -- "$SHRUNK/$f"
|
||||
fi
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user