I am looking to traverse a directory using a conditional for / while Loop
Scenario : path is /home/ABCD/apple/ball/car/divider.txt
Say I always start my program from /home I need to iterate from home -- > ABCD --> apple --> ball --> car --> divider.txt
Every time I iterate, check if the obtained path is a directory or a file, if file exit the loop and return me the path if the returned path is directory, loop one more round and continue..
Updated question
FILES="home"
for f in $FILES
do
echo "Processing $f" >> "I get ABCD as output
if[-d $f]
--> returns true, in my next loop, I should get the output as /home/ABCD/apple..
else
Break;
fi
done
after I exit the for loop, I should have the /home/ABCD/apple/ball/car/ as output