Mike Schilli's Friendly Neighborhood Perl Shop

Home
USArundbrief.com
Resume
CPAN Modules
Articles in English
Articles in German
Mike's Script Archive
English-Japanese Translation Trainer
Adventures with O'Reilly's Safari
10 Easy Steps to Become a California Driver
Unofficial perlmonks.com IRC Channel
My Collection of Outage Pages
Prisma (Computer Club Deutschland)
Mike's Monologues
Mike's Script Archive: symlinkdir

symlinkdir - Display the directory a symlink points to


NAME

    symlinkdir - Display the directory a symlink points to


DOWNLOAD

symlinkdir


SYNOPSIS

    symlinkdir


DESCRIPTION

This seemingly useless script saves considerable time if used during command-line-browsing through directories following symlinks.

symlinkdir displays the directory a symbolic link points to. If you're in /home/user and there's a symbolic link MyModule.pm which points to /home/user/projects/My/eg/MyModule.pm, you can quickly change to the directory the original MyModule.pm file is located in (/home/user/projects/My/eg) by typing

    cds MyModule.pm

given that your bash or similar shell defined a function

    function cds () { cd `symlinkdir $1`; pwd; ls; }

symlinkdir resolves symbolic links recursively, so if you have a link dir1 pointing to dir2 pointing to dir3, it will properly display dir2 when called on dir1/file.

If the link points to a directory instead of a file, symlinkdir will display this directory instead of going an additional level up.


LEGALESE

Copyright 2002 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


AUTHOR

Mike Schilli <m@perlmeister.com>


Latest update: 20-Oct-2013