[plug] Identifying hard linked files [was: Identifying harded files]

Tony Breeds magni at plug.linux.org.au
Thu May 8 13:40:27 WST 2003


On Thu, May 08, 2003 at 01:23:42PM +0800, Ryan wrote:
> Please excuse my earlier subject day dreaming :)

Scary thing is I knew what 'harded' meant ;P

> Lo PLUG,
> 
> How does one _easily_ identify hard linked files?

find . -type f -printf '%n:%f\n' | grep -v '^1:'
 
> Take for example a smylinked file - 'ls -l' will show it as:
> 
> -rwxrwxrwx    1 ryan    ryan      953704 Apr  2 07:40 file1 -> file2
> 
> 
> Now hard linked files - 'ls -li' will show it as:
> 
> 618955 -rwxrwxrwx    1 ryan    ryan     953704 Apr  2 07:40 file1
> 618955 -rwxrwxrwx    1 ryan    ryan     953704 Apr  2 07:40 file2
> 
> 
> In a big long list, the only way is to match up the inode numbers, which
> is rather labour intensive.
> 
> Is there any other way to find hard linked files in a directory - the
> purpose being to identify quickly for my eyes that the file is not
> actually another REAL file taking up storage space.

find <path> -links 1 -type f -ls
Should run 'ls -dils' on any files in <path> or below that only have one
link, any file with more than one link is hardlinked elswhere on the FS

You can probably to '! -links 1' to get just the linked files ?maybe?

Yours Tony

        Linux.Conf.AU       http://lca2004.linux.org.au/
        Jan 12-17 2004      The Australian Linux Technical Conference!



More information about the plug mailing list