coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] How to figure out all the hard links that link to the sa


From: Pádraig Brady
Subject: Re: [coreutils] How to figure out all the hard links that link to the same file?
Date: Tue, 27 Jul 2010 13:19:53 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 27/07/10 13:01, Eric Blake wrote:
> On 07/27/2010 01:30 AM, wayana wrote:
>> Hello,
>>
>> How about using 'find' ?
>>
>> $ find -inum $(ls -i a | cut -d ' ' -f 1)
>> ./b
>> ./a
> 
> That assumes they are in the same directory.  But in reality, the other
> link can be anywhere within the same device, so you need to figure out
> where the mount point is that contains ./a (I don't know of any tool
> that makes this easy, other than recursively checking devno of ., ..,
> and so forth until you find a difference), then use find -xdev to
> traverse the entire device looking for that -inum.  In general, not a
> trivial or fast operation.
> 
> Also, if you assume GNU utilities, $(stat -c %i a) is more efficient
> than $(ls -i a | cut -d ' ' -f 1).
> 
> Maybe the coreutils _should_ provide an easy way to get at the mount
> point that contains a given file (or which errors out because
> permissions don't allow determining that information).  But would that
> belong under stat(1), or some other tool?
> 

I'm going to merge this soon:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6555

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]