blax has asked for the wisdom of the Perl Monks concerning the following question:

If a file has hard links to it is there anyway to find out the names of those links?

For example, say I wanted to compress some man pages, and one of those man pages, gzip.1, has two hard links to it. Because gzip.1 has two hard links to it I cannot compress it unless I remove the other hard links, compress gzip.1, and then relink them with a .bz2 file extension.

Thanks,
blax

Replies are listed 'Best First'.
Re: Hard links
by Anonymous Monk on Jul 10, 2001 at 21:57 UTC
    If files are hard links they will have the same inode, you can get this information from stat but you'll have to stat every file on the filesystem until you've found all the links. In your case, I would use the -k flag to bzip2 to keep it from deleting the input file then copy the .bz2 file to the original file then delete the .bz2 file.
      And how do you change the extension? Another example why extensions for fileformat are BAD!
        There is no such thing as an extension in most if not all unix-like filesystems. '.' is simply a valid filename character.

        'The fickle fascination of and Everlasting God' - Billy Corgan, The Smashing Pumpkins
        To change a file's extension, you rename it.