[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: remove paths
From: |
Tim Mooney |
Subject: |
Re: remove paths |
Date: |
20 Jul 2001 20:27:03 GMT |
In article <3B584994.7000806@linux.ie>, Padraig Brady <Padraig@linux.ie> wrote:
> ?
> newpath=`echo $PATH | tr : '\n' | uniq | tr '\n' :`
Nice trick, but to work sorrectly, uniq must have sorted output. That
means that you would need either sort before uniq or just a `sort -u'
in there.
The problem is, that's going to re-arrange your PATH, which is not
a good thing.
It's too bad there wasn't a way to make sed delete the *last* occurrence
of a regex on a line, rather than the default behavior of deleting the first
(absent the `g' option). It would be relatively trivial to do it that way,
if sed could easily do this. Of course, now that I think about it, because
regexes are greedy you could get rid of the last occurrence of a component
fairly easily. Handling path components that happen more than twice in
the PATH would require multiple runs, though, so Paul's solution is probably
still better.
Tim
--
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services (701) 231-1076 (Voice)
Room 242-J6, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164