setup.sh 602 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. set -e
  3. files=10
  4. folders=2
  5. depth=4
  6. target="$PWD/target"
  7. rm -rf target
  8. fill () {
  9. local depth=$1
  10. local files=$2
  11. local folders=$3
  12. local target=$4
  13. if ! [ -d $target ]; then
  14. mkdir -p $target
  15. fi
  16. local f
  17. f=$files
  18. while [ $f -gt 0 ]; do
  19. touch "$target/f-$depth-$f"
  20. let f--
  21. done
  22. let depth--
  23. if [ $depth -le 0 ]; then
  24. return 0
  25. fi
  26. f=$folders
  27. while [ $f -gt 0 ]; do
  28. mkdir "$target/folder-$depth-$f"
  29. fill $depth $files $folders "$target/d-$depth-$f"
  30. let f--
  31. done
  32. }
  33. fill $depth $files $folders $target
  34. # sanity assert
  35. [ -d $target ]