Variables are easy to do

Variables are easy to do

In my Amiga and MS-DOS days, I recall to set a variable you had to use a set command. Everytime I’m in a POSIX based system, I always forget how to set variables and the sad thing is its fricken easier than the mainstream systems….(mental note: gotta pick where to use the word mainstream these days.)

So to set a variable:


Thats it!

It’ll make you feel stupid just looking at it. No keywords, the syntax is built into the shell directly.

You then want to export this variable to an environment value so that a variable can become global, not just to the shell or script instance that it executes in. To do this


Ok, and since I’m on the topic, I may as well tell you about how variables are referenced.

$VARIABLE_NAME will substitute the variable value in your command. You can do things like handle spaces in values by surrounding $VARIABLE_NAME in double quotes.

If you actually want to print out verbatim the text `$VARIABLE_NAME’ then the key is to open the text with a backquote (`) instead.

Leave a Reply