LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 10-02-2008, 01:43 PM   #1
muasif80
Member
 
Registered: Oct 2008
Posts: 54

Rep: Reputation: 15
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

http://linux-certification.blogspot....-symbolic.html



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]

for example

root@xyz# find / -samefile file1

or

root@xyz# find . -samefile file1

You can also use the inode number for searching the hard links to it

for example

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"

or

root@xyz# find / -lname "*file1"

Last edited by muasif80; 10-02-2008 at 01:48 PM. Reason: Changing the title of the post
 
Old 10-04-2008, 11:10 PM   #2
jgallo
Member
 
Registered: Sep 2008
Posts: 39

Rep: Reputation: 15
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

Last edited by Tinkster; 10-30-2010 at 04:57 PM.
 
  


Reply

Tags
hard, link, list, soft


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
technical question about hard links v soft links 7stud Linux - Newbie 2 02-23-2007 07:57 PM
Is this how links (soft/hard) work? RHLinuxGUY Linux - General 1 10-14-2006 11:06 PM
links (hard links and soft links..) sachitha Programming 1 08-10-2005 01:10 PM
Soft vs. Hard Links jrdioko Linux - Newbie 2 06-13-2004 03:41 PM
Hard/Soft Links nodger Linux - General 1 05-15-2004 11:36 AM


All times are GMT -5. The time now is 01:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration