Reputation: 1289
I want to add a path to my PATH
variable which includes the lowercase name of the OS. I can do the following now:
osname=$(uname -s)
osname=${osname,,}
export PATH="${HOME}/this/that/${osname}/bin"
Is there a way to write this on a single line, avoiding the variable itself?
Upvotes: 0
Views: 234
Reputation: 15246
Don't try to embed an execution in your PATH if you can avoid it.
declare -l osname="$(uname -s)" && export PATH="${HOME}/this/that/${osname}/bin";
Upvotes: 2
Reputation: 1963
This is the way
export PATH=$PATH:${HOME}/this/that/$(uname -s | tr '[:upper:]' '[:lower:]')/bin
I added $PATH at the beginning of the value since I guess you don't want to loose your actual $PATH
Upvotes: 1