Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Last active April 11, 2016 14:48
Show Gist options
  • Save carlessanagustin/ac1783f21d109c1a87452f238de3a7fd to your computer and use it in GitHub Desktop.
Save carlessanagustin/ac1783f21d109c1a87452f238de3a7fd to your computer and use it in GitHub Desktop.
Append environment variable PATH with SED
#!/bin/bash
PATHOK="`grep myprog /etc/environment`"
if [ -z $PATHOK ]; then
sed -e '/^PATH/s/"$/:\/usr\/lib\/myprog\/bin"/g' -i /etc/environment
fi

/etc/environment

Before

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

After

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment