Here I need a shell script which will remove rmv path (test/rmve) from PATH (/usr/local/bin:/usr/bin:test/rmve:/usr/games) and update the PATH as /usr/local/bin:/usr/bin:/usr/games
I have used the following line for this
PATH=$(echo $PATH | sed -e 's;:\?'$rmv';;' -e 's;'$rmv':\?;;')
export $PATH
This is working fine only in Linux but not in AIX or Sun or any other OS
When defining a variable there may be no spaces left and right of the equal sign. This will not even work on Linux usually. Also that 1st echo outside $() is useless.
I did not check the rest but try it with this and add an export to make it work:
PATH=$(echo $PATH | sed -e 's;:\?'$APPLYPTF_DIR';;' -e 's;'$APPLYPTF_DIR':\?;;')
export PATH
rmpath() #@ remove directory or directories from $PATH
{ #@ USAGE: rmpath dir ...
for p in "$@"
do
p=${p%"${p##*[!/]}"} ## remove trailing slashes
case $PATH in
"$p":*) PATH=${PATH#$p:} ;; ## at beginning of PATH
*:"$p") PATH=${PATH%:$p} ;; ## at end of PATH
*:"$p":*) PATH=${PATH%":$p"*}${PATH##*"$p"} ;;
esac
done
export PATH
}