find . -type d -exec cd {} \;

Hi all
Can anyone tell me why this is not working ?
i saw somewhere that i must have serach (execute) permission which i have
but it still wont work
thx

I don't think you can call cd using exec, because it is a builtin command, meaning it is part of the code that makes up the shell.

Cheers,
LePiaf

Most versions of unix have an external program called cd because Posix, in its wisdom, requires this. An external cd program is terribly useless. In the find example posted by the OP, the cd program runs as a separate process, it does indeed attempt a chdir() system call into the specified directory. Then it exits, leaving the parent process' current directory unchanged. The exit indicated whether or not it succeeded.

Sometimes stuff like acl's can affect whether or not you can cd into a directory. To produce a list of those directories into which you cannot cd, you could do:

find . -type d ! -exec /usr/bin/cd {} \; -print 2>/dev/null

That is about the only use I can find for an external cd program.