D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Find hard links

 

Steve Marvell wrote:
> Simon Waters wrote:
> 
>> GNU find does that, and handles symbolic links.
>>
>> "man find"
>>
>> check "links" and "samefile" and "-L" options
> 
> My version on Debian stable does not have these options.

"samefile" is from July 2005 so it may not have made it to Sarge.

"links" is ancient.

inum can be used in place of samefile, as that just saves looking up the
inode number first, but you lose the symbolic link support.

On a sarge box....

simon@mail:~$ mkdir tmp
simon@mail:~$ cd tmp
simon@mail:~/tmp$ touch a
simon@mail:~/tmp$ ls -i a
458482 a
simon@mail:~/tmp$ ln a b
simon@mail:~/tmp$ find . -inum 458482
./a
./b
 simon@mail:~/tmp$ find . -type f -links +1
./a
./b
simon@mail:~/tmp$ rm b
simon@mail:~/tmp$ find . -type f -links +1
simon@mail:~/tmp$

There is a Perl command (find2perl) for turning "find" command into
Perl, which can be handy for writing special cases on top of the "find"
command, but it helps if your Perl writing ability is more like Steve's
than mine.

find2perl is missing a few options (i.e. can't translate them from
find), at least one of which I think (+perm IIRC) I filed a wishlist bug
against, and is probably only a few minutes work for an experienced perl
hacker, as 90% of the code is already there for "-perm".

Perl find is faster for some cases, but don't tell the C coders that
it'll make them cry and they'll probably optimise it away ;)

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html