rmfiles (821B)
1 #!/bin/sh 2 3 . ./lib/env.sh 4 . ./lib/fun.sh 5 6 rmlist=./lib/rmlist.tsv 7 currentstep=$1 8 9 startuid=$(id -u) 10 11 recno=0 12 IFS=$(printf '\n') 13 while read -r record 14 do 15 recno=$((recno+1)) 16 17 if [ "${recno}" -eq 1 ]; then 18 continue 19 fi 20 21 path=$(printf "${record}" | cut -d "$(printf '\t')" -f1) 22 step=$(printf "${record}" | cut -sd "$(printf '\t')" -f2) 23 24 # If no step was passed, do all 25 if [ -n "${currentstep}" ] && \ 26 ! { echo "${step}" | grep "${currentstep}" >/dev/null 2>&1; } 27 then 28 continue 29 fi 30 31 if [ -z "${path}" ]; then 32 msg warn "Empty path at record #%d; skipping" "${recno}" 33 continue 34 fi 35 36 if [ -d "${GR}${path}" ]; then 37 msg info "rm -fr %s" "${GR}${path}" 38 rm -fr "${GR}${path}" || exit 1 39 elif [ -e "${GR}${path}" ]; then 40 msg info "rm -f %s" "${GR}${path}" 41 rm -f "${GR}${path}" || exit 1 42 fi 43 done <${rmlist}