Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function rec {
- local x=$1
- if test $1 -lt 5
- then
- ((x++))
- echo "rec $x"
- rec $x
- else
- echo $x
- fi
- }
- function makedirs {
- mkdir -p 1/2/5 1/2/6 1/3 1/4/7 1/4/8
- }
- function getsubdirs {
- subdirs=()
- currentdir="$1"
- for i in "$currentdir"/*;do
- if test -d "$i"; then
- #~ echo addsub "$i" 1>&2
- subdirs+=("$i")
- fi
- done
- }
- function printcontent {
- for i in "$1"/*; do
- echo $i
- #~ echo "`du -h "$i"|cut -f1`" "$i"
- done
- }
- function dfspreorder {
- local currentdir="$1"
- echo preorder "$1"
- getsubdirs "$currentdir"
- for subdir in "${subdirs[@]}"; do
- dfspreorder "$subdir"
- #~ echo inorder "$currentdir"
- done
- #~ echo postorder "$currentdir"
- }
- function dfsinorder {
- local currentdir="$1"
- getsubdirs "$currentdir"
- for subdir in "${subdirs[@]}"; do
- dfsinorder "$subdir"
- echo inorder for "$currentdir"
- done
- echo inorder afterfor "$currentdir"
- }
- function dfspostorder {
- local currentdir="$1"
- getsubdirs "$currentdir"
- for subdir in "${subdirs[@]}"; do
- dfspostorder "$subdir"
- done
- echo postorder "$currentdir"
- }
- count=0
- subdirs=()
- #rec 0
- #recdir `pwd`
- rm -rf 1
- makedirs
- root=`realpath 1`
- dfspreorder "$root" #ok
- dfspostorder "$root" #ok
- dfsinorder "$root" #ok
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement