summaryrefslogtreecommitdiff
path: root/bin/extra/wipe
blob: 6006b8eed6af445b7750917b7b96d7e1c9120170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
[ 0 -eq "$#" ] && >&2 echo 'usage: wipe <file>' && exit 1
[ ! -f "$1" ] && [ ! -d "$1" ] && >&2 echo "'$1' not found." && exit 1

printf "sure? "
[ "$(head -n 1)" != "y" ] && exit 1

find "$1" -type f -print0 |
	xargs -0I{} shred -uz "{}" &&
	[ -d "$1" ] && # remove leftovver empty directories
	find "$1" | tac | tr '\n' '\0' |
	xargs -0I{} rm -d "{}" &&
	>&2 echo "wiped."