Listing hard and soft links to a file!
I have the following text after the url for explaining how we can list hard and soft links to a file. If anyone can share his knowledge on this subject, I will be happy to know about that. For more information about hard and soft links you can see at the following url
How can we list all of the hard links or soft links to a particular file?
List Hard Links
You can list all of the hard links to a file 'file1' by using the following command
root@xyz# find [directory to search] -samefile [file name (which can be any hard link) as argument]
root@xyz# find / -samefile file1
root@xyz# find . -samefile file1
You can also use the inode number for searching the hard links to it
root@xyz# find . -inum [inode number]
You can find the inode number of a file by using the following command
root@xyz# ls -i
List Soft Links
You can list the soft links to a file using the following command
root@xyz# find -lname file1
It is better to put a * as prefix in the file name like below
root@xyz# find -lname "*file1"
Because we have not mentioned the directory where the search should be made so the search will be made in the current directory. We can mention the directory where the search should be made in the following way
root@xyz# find . -lname "*file1"
root@xyz# find / -lname "*file1"
If I understand what you are asking...you will just need to add "> filename" to the end of any of those commands(without the qoutes) and all of the output will be sent to the file called filename
|All times are GMT -5. The time now is 06:26 PM.|