[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Steve Marvell wrote: > Simon Williams wrote: > >> I've got some files which I have been hard linking to save time and >> space. Now I'm trying to reorganise those files, but I don't know what >> links to what. >> >> Is there some command which will list all the files pointing to the same >> data? > > Not that I know of, so I wrote this little script of pleasure. > > Steve > > > #! /usr/bin/perl > > use File::Find; > > my $dir = $ARGV[0] || '.'; > > my $nodes; > > sub wanted { > > my ($inode,$nlink) = (lstat($_))[1,3]; > > return unless -f && $nlink > 1; > > push(@{$$nodes{$inode}}, $File::Find::name); > } > > File::Find::find({wanted => \&wanted}, $dir); > > print map { "@$_\n" } values %$nodes; Thankyou very much, that's very useful. However, I have no knowledge of perl and so don't know how it works. I was also hoping for something which would let me specify a file and it would go find all the other links to that data (perhaps given a dir to look in). Would I be right in thinking that the only way to get such a list is to check every file and see where it lives? Or is there a list of pointers to data somewhere? Thanks again Simon -- 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