How can I loop through directories and restrict the depth to only 3 levels? My version of find does not have -maxdepth. I'd like to keep it to one line if possible.
e.g: find /data -type d -print
Any help would be much appreciated. Thanks.
shopt -s nullglob
for d in /data/*/ /data/*/*/ /data/*/*/*/
do
echo "$d"
done
-type d though; using [ -d "$d" ] && echo "$d" would, and you could drop setting nullglob then.