#!/bin/sh # For people who eat megabytes like corn chips.. # # Inspired by overflowing partitions and the pretty shell # code in Tales from the Abyss: UNIX File Recovery (SysAdmin # Mag) at http://www.samag.com/documents/s=1441/sam0111b/0111b.htm # You can also do things in shell like: # for i in `find . `; do file $i | grep ASCII ; done # Or replace $1 with a directory and paste from "find" at prompt. # No need to shy away from the command line! read man bash # (or man tcsh) and get results fast. # echo "Recursive search for symbolic links. Usage: findlinks dirname"; find $1 | file -f - | grep link\ to | awk -F: '{print $2 "\t" $1}' | sort -b +1 | perl -e ' $sy = "symbolic link"; $sb = "broken symbol"; $sl = length($sy); while (<>) { $m=$_; $m =~ s/^\s+//; $n = $m; $n =~ s/^(.+)\t(.+)$/$2\t\($1\)/; #WAS $n =~ s/^(.+)\t(.+)$/$2/; if (substr($m,0,$sl) eq $sy) {push @sys,$n;} elsif (substr($m,0,$sl) eq $sb) {push @sbs,$n;} else {push @oth,$n;} #for debug } print "\n** Symbolic Links:\n", @sys, "\n** Broken Symbolic Links:\n", @sbs; print "\nOthers:\n", @oth unless $#oth<0; '