Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:
share|improve this question
up vote 9 down vote accepted

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:\

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

share|improve this answer
Note that export is a built-in command, not a keyword nor a syntactic assignment. So if you have PATH elements containing whitespace (or glob characters), you do need double quotes around export PATH="$PATH:B". You could also write PATH=$PATH:B and so on; you only need to export a variable once, not every time it changes (except in some very old Bourne shells), and you don't need the double quotes in an assignment. – Gilles May 17 '11 at 20:37
Also PATH+=:B works for string concatenation. – Aryeh Leib Taurog Jul 17 '13 at 20:24

You can extend lines in bash using a backslash at the end of a line like this:

export PATH=/path/A:\

Please note that the absence of white space is important here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.