Bash – Multiple path environment variable setup lines with bash

bashenvironment-variablespath

I have very long export PATH=A:B:C .... Can I make a multiple lines to have more organized one as follows?

export PATH = A:
              B:
              C:

Best Answer

You can do:

export PATH="A"
export PATH="$PATH:B"
export PATH="$PATH:C"

Each subsequent line appends onto the previously defined path. This is generally a good habit, as it avoids trashing the existing path. If you want the new component to take precedence, swap the order:

export PATH="A"
export PATH="B:$PATH"
export PATH="C:$PATH"

Alternatively, you might be able to do:

export PATH=A:\
B:\ 
C

where \ marks a line continuation. Haven't tested this method.

Related Question