Reputation: 5470
I've multiple MPI variations on my system. Each one is used for compile of specific application. I am looking for an script to exclude specific dir from $PATH to wrap application execution with the corresponding MPI. Is there any simple way to do so?
Upvotes: 2
Views: 1353
Reputation: 4107
Perhaps something along the lines of:
with-excluded-path () {
echo "$PATH" | sed "s,$1:,,g"
}
or
with-excluded-path () {
echo "$PATH" | awk -vORS=":" -vRS=":" '$1 == "'$1'" { next }; {print $1}'
}
PATH=$(with-excluded-path "/path/to/exclude") /bin/application
Or simply add the desired MPI path to the head of PATH:
export PATH="/opt/the/mpi/i/want:$PATH"
Upvotes: 8