How to recursively list subdirectories in Bash without using "find" or "ls" commands?
bash
Solution
you can do it with just the shell
#!/bin/bash
recurse() {
for i in "$1"/*;do
if [ -d "$i" ];then
echo "dir: $i"
recurse "$i"
elif [ -f "$i" ]; then
echo "file: $i"
fi
done
}
recurse /path
OR if you have bash 4.0
#!/bin/bash
shopt -s globstar
for file in /path/**
do
echo $file
done
Problem
I know you can use the `find` command for this simple job, but I got an assignment not to use `find` or `ls` and do the job. How can I do that?