2
0

clean-package.sh 430 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. IFS=$'\n'
  3. [ -n "$1" -a -n "$2" ] || {
  4. echo "Usage: $0 <file> <directory>"
  5. exit 1
  6. }
  7. [ -f "$1" -a -d "$2" ] || {
  8. echo "File/directory not found"
  9. exit 1
  10. }
  11. cat "$1" | (
  12. cd "$2"
  13. while read entry; do
  14. [ -n "$entry" ] || break
  15. [ -f "$entry" ] && rm -f $entry
  16. done
  17. )
  18. sort -r "$1" | (
  19. cd "$2"
  20. while read entry; do
  21. [ -n "$entry" ] || break
  22. [ -d "$entry" ] && rmdir "$entry" > /dev/null 2>&1
  23. done
  24. )
  25. true