This question already has an answer here:

I technically know how to do all these things, but combining it is problematic. Inode is saved in first line of text file (I can eventually read it directly from file), I need results saved to the same file.

How can I do this?

marked as duplicate by pLumo, Philip Couling, mosvy, Prvt_Yadav, meuh May 26 at 16:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can use find utility with -inum parameter. From man 1 find:

-inum n

File has inode number n. It is normally easier to use the

-samefile test instead.

  • I have tried "locate -inum ls -i /home/user/file | cat>file2" and it's giving me error "locate: invalid value 'um' of --limit". I have found that locate is used to find files in whole system. – Corporal Girrafe May 24 at 16:24
  • @Corporal Girrafe Please, use find instead of locate. – Yurij Goncharuk May 24 at 19:29
  • But won't find search only in folder where script is located? – Corporal Girrafe May 25 at 17:44
  • I have came up with something like that - find -ls ln -i /home/user/folder/file | cat>>save but i get find: paths must precede expression ln error. And this is the issue, i don't have the path, i want to search in whole system. – Corporal Girrafe May 25 at 19:45

You can use find command with the argument -inum with inode number like as below


touch /home/ajeet/original_file.txt
ln /home/ajeet/original_file.txt /root/hard_link_file.txt

ls -li /root/hard_link_file.txt
1704088 -rw-r--r-- 2 root root 0 May 24 18:24 /root/hard_link_file.txt

ls -li /home/ajeet/original_file.txt
1704088 -rw-r--r-- 2 root root 0 May 24 18:24 /home/ajeet/original_file.txt

find / -inum 1704088

Not the answer you're looking for? Browse other questions tagged or ask your own question.