I wonder...

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`
Posted by cjj at 10:56 PM
Labels: code

1 comment:

Anonymous said...

nice. we made the same, but in perl

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

May 5, 2009 at 5:53 AM

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Published articles

Loading...

Memory?

  • ►  2014 (2)
    • ►  March (1)
    • ►  January (1)
  • ►  2012 (2)
    • ►  July (1)
    • ►  June (1)
  • ►  2011 (5)
    • ►  September (1)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2010 (7)
    • ►  October (2)
    • ►  July (1)
    • ►  June (1)
    • ►  May (3)
  • ►  2009 (2)
    • ►  October (1)
    • ►  February (1)
  • ►  2008 (13)
    • ►  December (1)
    • ►  September (1)
    • ►  August (1)
    • ►  June (1)
    • ►  May (1)
    • ►  April (3)
    • ►  March (2)
    • ►  February (2)
    • ►  January (1)
  • ▼  2007 (25)
    • ►  December (2)
    • ▼  November (3)
      • The Chase is On
      • first snow
      • remove duplicate paths from $PATH in BASH
    • ►  October (1)
    • ►  August (1)
    • ►  March (3)
    • ►  February (12)
    • ►  January (3)

Labels

  • code (11)
  • gadget (1)
  • hack (7)
  • software (6)
Powered by Blogger.