// Internet Duct Tape

symbolic link checker in Perl and script to find biggest files

Posted in Links, Linux and Unix, Perl, Technology by engtech on April 27, 2006

These are a couple of perl utilities I've found useful.

linkcheck.pl is for finding broken symbolic links. biggest.sh is for finding the largest file on a file system (ie: when you've run out of diskspace and you need to find the culprit)

linkcheck.pl looks for all links on the local file system and tests each link's integrity–to determine whether the link still valid, or if it points to an object that no longer exists. Only local filesystems are searched and this is ensured by testing each filesystem argument via "df -l" command.

Listing broken links is helpful, and you can certainly write a much shorter Perl program to do that, but linkcheck.pl comes with other useful options:

    -a Display All links
    -H Detailed documentation
    -h Usage brief
    -l Long list (e.g., ls -al)
    -r Remove broken links (use with caution)
    -v Verbose output
    fs Required filesystem for search (multiple filesystems may be specified)

How many times has a file system filled up causing you to spend more time than you liked finding that hernia file or files? I'll wager more times than you care to remember. After I lived with that aggravation for way too long, I put together biggest.sh.

Biggest.sh has run successfully on Sun Solaris and Linux. It is written in Bourne shell (instead of Korn or Bash) for one reason only – portability. The script runs under Bourne, Korn, and Bash environments without modification.

   Usage: biggest.sh -fHh -l <nn> -v -t <dir> -s <nnn> fs     -f - Follow links
     -H - Displays detailed documentation
     -h - Provides usage brief
     -l - Displays <nn> lines (default is 500)
     -s - Minimum file size is <nnn> (default is 500K)
     -t - Use <dir> as temp/work directory (default is /var/tmp)
     -v - Edit (vi) file list
     fs - Required file system argument

Bob Orlando's Unix Tools

Comments Off on symbolic link checker in Perl and script to find biggest files

%d bloggers like this: