Validating Symlinks

Validating Symlinks

symlinkCheck.rb

Symlinks, or symbolic links, are awesome for a lot of reasons: They simplify obnoxiously long path names; you can put them anywhere you like; you can call them whatever you want; and they are generally transparent to the user. While symlinks can do magical things, they really suck when they become orphans (that is, no longer point to a valid target). So, in an effort to uphold the symlink reputation, I wrote this script to clean up after myself … and others. It's a housekeeping script.

The Code

 #!/usr/bin/ruby

 unless File.directory?(ARGV[0]) puts "Not a valid directory...\nCheck path and try ...

Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.