push and pop directories and subdirectories

I need to use pushd and popd to navigate all of the subdirectories in my current directory.

I know how to get into each subdirectory, add it to the stack, and pop back out, but i cant figure out how to get into subdirectories deeper than the first without adding a foreach and if statement for each level.

If there a while loop solution to this?

foreach x (`ls`)
        if(-d $x)then
                pushd $x
                echo $x
                popd
        endif
end



I am working in UNIX

Why do you need pushd and popd to do that?

They are not standard commands, and are found only in bash and csh, and csh is not recommended for scripting:

Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful