Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- open LINKS, 'find ' . $ARGV[0]. ' -type f|awk \'{ system("stat -c \"%n %i %a %U:%G %h\" \"" $1 "\""); }\'|egrep \' ([0-9]{2,10}|[2-9])$\'|';
- my @links;
- #Converting to array
- for ($i=0;<LINKS>;$i++)
- {
- ($links[$i][0], $links[$i][1],$links[$i][2],$links[$i][3],$links[$i][4])=split(' ',$_);
- }
- printf "Found $i links\n";
- for (my $i=0;$links[$i];$i++)
- {
- $source=$links[$i][0];
- $inode=$links[$i][1];
- if ($links[$i][5]) { next; } #Skip corrected
- printf "Searching for links of $source (inode $inode)...\n";
- for ($j=0;$links[$j];$j++)
- {
- if ($links[$j][1]==$inode && $source ne $links[$j][0])
- {
- $links[$j][5]=1;
- printf "Found: $links[$j][0]\n. Recreating...";
- $a=`rm -rf $links[$j][0]`;#Delete
- #$a.=`echo touch $links[$j][0]`;#Touch
- $a.=`cat $source > $links[$j][0]`;#Copy
- $a.=`chmod $links[$j][2] $links[$j][0]`;
- $a.=`chown $links[$j][3] $links[$j][0]`;
- printf "$a\n";
- }
- }
- #exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement