Created
June 3, 2013 08:36
-
-
Save unok/5696886 to your computer and use it in GitHub Desktop.
PATH の中の重複したパスを削除する。どこかでひろってきたのをそのまま利用w
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_duplicate_path(){ | |
eval "export PATH=$(perl -e ' #\ | |
my $e = shift; #\ | |
for(split q/:/, $ENV{"PATH"}){ #\ | |
if("$_" ne "" && -e "$_"){ #\ | |
$n{$_} or $n{$_} = ++$i; #\ | |
} $\ | |
} #\ | |
$, = q/:/; #\ | |
%n = reverse %n; #\ | |
print map { $n{$_} } #\ | |
sort { $a <=> $b } keys %n #\ | |
')" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment