Tuesday, 23 April 2013

Unix: Change Directory using its Inode Number

Lets Suppose you have downloaded a Directory/Folder which have an odd name that cannot be used with "cd" command . 

For Example " -ROOT ",you will get error as follows:

If you try to run command ,you will get an error as follows:

 cd -ROOT

 cd: -R: invalid option

So you can "cd" to this directory using its inode number which you can get running "ls -i" in the directory where it is placed. For example its inode number is :

5511344 -ROOT-

Now since "cd" is a shell utility not a command so you cannot do

find . -inum 5511344 -exec cd {} \;          ------------ Incorrect

In order to "cd" using Inode you can run following command:

cd $(find . -inum 5511344)

No comments:

Post a Comment