Closed Captioning Closed captioning available on our YouTube channel

How to use the export command: 2-Minute Linux Tips

Network World | Sep 10, 2021

In this Linux tip, learn how to use the export command. It's a bash built-in that allows command line variables to be available to a child process – a second shell or a script that you run.

Copyright © 2021 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the export command. It's a bash built-in that allows command line variables to be available to a child process – a second shell or a script that you run. To illustrate, I'm going to set up a variable:

Now, I'll start a subshell like this and attempt to display the variables:
The variable doesn't exist in the subshell. So, we exit the second shell and export it before starting another subshell:
We then exit the subshell again.
Similarly, if you run a script that expects a command line variable to be available and you don't export it, the script won't see it, but if you export it, it will be available.
That’s your Linux tip for the export command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Popular
Featured videos from IDG.tv