Categories
Linux Tutorial Series

Linux Tutorial Series – 86 – Shell variables

Here is the video version, if you prefer it:

Let’s talk about shell variables today. Shell variables are temporary variables specific to the shell you are currently running. (Ward, 2014)⁠ Think of it like this – shell variables are temporary, environment variables are permanent.

Here is an example of setting and printing out the contents of a shell variable:

mislav@mislavovo-racunalo:~$ VARIABLE=stuff

mislav@mislavovo-racunalo:~$ echo $VARIABLE

stuff

If I try to print the contents of VARIABLE in another shell, I get:

mislav@mislavovo-racunalo:~$ echo $VARIABLE

What’s that I get? An empty line. Because in another shell (in another Terminal window), the variable VARIABLE doesn’t exist.

Hope you learned something useful!

References

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 21-22

NewsletterUpdates on interesting things I am doing

Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.

Leave a Reply

Your email address will not be published. Required fields are marked *