2021-06-02 11:01:11 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# safe delete with find and rm, logged
|
2021-06-02 11:02:50 -05:00
|
|
|
# 2019 Dave Bechtel
|
2022-01-26 23:12:26 -06:00
|
|
|
# EDIT BEFORE USING!!
|
|
|
|
|
|
|
|
# to stderr only
|
|
|
|
>&2 echo "NOTE use this script at your own risk, I take NO responsibility for data loss!"
|
2021-06-02 11:01:11 -05:00
|
|
|
|
2021-06-02 11:02:50 -05:00
|
|
|
#source ~/bin/failexit.mrg
|
|
|
|
# failexit.mrg
|
|
|
|
function failexit () {
|
|
|
|
echo '! Something failed! Code: '"$1 $2" # code # (and optional description)
|
|
|
|
exit $1
|
|
|
|
}
|
2021-06-02 11:01:11 -05:00
|
|
|
|
2021-06-02 11:02:50 -05:00
|
|
|
# xxxxx TODO CHANGEME
|
2021-06-02 11:01:11 -05:00
|
|
|
dest=/mnt/tmp
|
|
|
|
|
|
|
|
logfile=~/safeRM.log
|
|
|
|
> $logfile # clearit
|
|
|
|
|
|
|
|
cd "$dest" || failexit 99 "! Unable to cd to $dest"
|
|
|
|
|
2021-06-02 11:02:50 -05:00
|
|
|
# xxxx TODO CHANGEME wildcard files
|
2021-06-02 11:01:11 -05:00
|
|
|
time find -P "$dest"/* -mount -name "*.wav" -type f -exec /bin/rm -v {} >> $logfile \;
|
|
|
|
|
|
|
|
ls -alh $logfile
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
REF: http://unix.stackexchange.com/questions/167823/find-exec-rm-vs-delete
|