Friday, November 2, 2007

remove duplicate paths from $PATH in BASH

Here is one that I came up with:
PATH=`awk -F: '{for(i=1;i<=NF;i++){if(!($i in a)){a[$i];printf s$i;s=":"}}}'<<<$PATH`

1 comment:

Anonymous said...

nice. we made the same, but in perl

http://linsovet.com/perl-1liner-remove-duplicate-from-PATH