Skip to content

Instantly share code, notes, and snippets.

@unok
Created June 3, 2013 08:36
Show Gist options
  • Save unok/5696886 to your computer and use it in GitHub Desktop.
Save unok/5696886 to your computer and use it in GitHub Desktop.
PATH の中の重複したパスを削除する。どこかでひろってきたのをそのまま利用w
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