Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set -f path=("/new/entry" $path:q)
- set -f path=('/new/'e"ntry" $path:q)
- set -f path=(/'new/entry' $path:q)
- set path=(/new/entry $path:q)
- set -f path=($path:q)
- if ( $PATH =~ */some/path* ) then
- set PATH = ($PATH:/some/path)
- endif
- UNIQUE_LIST=$( echo "$PATH" | tr ':' 'n' | sort | uniq)
- # then we place in front those from UNIQUELIST that match an ordered list
- # note that that way, those who didn't have "/sbin" still won't have it, but if they did
- # it will be at the right place in the list
- shouldbefirst="/bin /sbin /usr/bin" # complete or re-order as needed on your system...
- for dir in $shouldbefirst
- do
- if ( echo "$UNIQUE_LIST" | grep "$dir" >/dev/null 2>/dev/null)
- then #we have this dir in UNIQUE_LIST
- NEWLIST="${NEWLIST}:${dir}"
- UNIQUE_LIST="$( echo "$UNIQUE_LIST" | grep -v "^$dir$")" #we treated that one, take it out of the original list
- fi
- done
- # then put the remaining of UNIQUE_LIST in the order you want (here, alphabetically)
- for dir in $UNIQUE_LIST
- do
- NEWLIST="${NEWLIST}:${dir}"
- UNIQUE_LIST="$( echo "$UNIQUE_LIST" | grep -v "^$dir$")" #we treated that one, take it out of the original list
- done
- # get rid of possible first ":" (as NEWLIST starts empty)
- NEWLIST="$(echo "$NEWLIST" | sed -e 's/^://')"
- # and then : (I test by placing "echo" in front, get rid of "echo" if it looks fine)
- echo PATH="$NEWLIST"
Add Comment
Please, Sign In to add comment