carlessanagustin
4/11/2016 - 2:46 PM

Append environment variable PATH with SED

Append environment variable PATH with SED

/etc/environment

Before

PATH="/usr/bin:/usr/local/bin"

After

PATH="/usr/bin:/usr/local/bin:/usr/lib/myprog/bin"

#!/bin/bash

PATHOK="`grep myprog /etc/environment`"

if [ -z $PATHOK ]; then
    sed -e '/^PATH/s/"$/:\/usr\/lib\/myprog\/bin"/g' -i /etc/environment
fi