Unix shell: prepend path if not prepended already 

Joined:
04/09/2007
Posts:
784

September 22, 2013 09:07:10    Last update: September 22, 2013 09:07:10
I want to prepend /usr/java/bin to $PATH, if /usr/java/bin is not prepended already. There's no harm if you prepend /usr/java/bin multiple times, but $PATH looks ugly.

$ PATH=/usr/java/bin:${PATH#/usr/java/bin:}
Share |
| Comment  | Tags