Uys of Spades
Uys of Spades

Reputation: 569

Writing Variable Text-Name to file via shell script

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?

Upvotes: 0

Views: 33

Answers (1)

theorifice
theorifice

Reputation: 690

You can just escape the $ character:

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

Upvotes: 2

Related Questions