0

Very simple question with a complicated solution that I haven't been able to find online. Maybe I am wording my questions wrong in google.

Its very simple I want to add to my .bash_profile file exporting a new directory to my $PATH via shell script. Something like this:

echo "export /usr/local/slope-stability/bin:'$PATH'" >> ~/.bash_profile

However I want the $PATH to be written as $PATH not as the actual content the variable contains. Right now when I execute this I get

export /usr/local/slope-stability/bin:

written to my file along with all the content of my current $PATH as well.

Anyway I can just actually add the text $PATH instead of the content?

1 Answer 1

2

You can just escape the $ character:

echo "export /usr/local/slope-stability/bin:\$PATH" >> ~/.bash_profile
Sign up to request clarification or add additional context in comments.

1 Comment

or "terminate" the dbl-quoting, and just have single-quoting for '$PATH', i.e. echo "export /usr/local/slope-stability/bin:"'$PATH' >> ~/.bash_profile . Good luck to all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.