Search code examples
findinode

Two ways of entering a directory by inode number?


If I want to enter a directory by its inode number, why

cd $(find . -inum $inode_num) 

works, but the following command does not work:

find . -inum $inode_num -exec cd {} \;

what's the difference between these two, and why is the 2nd one wrong?


Solution

  • cd is not a program that can be executed, it's a built-in shell command. It has to be, since it's too hard to change current directory in parent process.