According to the manpage, `-e` is for multiple commands - i think you can just do `sed -e "s#$NVM_DIR/[^/]*$2[^:]*##g" -e "s/::/:/g" -e "s/:$//g"` here?