ansitest/saferm.sh

29 lines
587 B
Bash
Raw Normal View History

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
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