The export command in a Unix-like shell is used to set environment variables or mark variables for export to child processes. When you export a variable, it becomes available to any subprocess or shell that is spawned from the current shell.
Syntax:
export VARIABLE_NAME=value
Example:
-
Setting an Environment Variable:
export MY_VAR="Hello, World!" -
Accessing the Variable:
You can access this variable in the current shell or any child processes:echo $MY_VAR -
Listing Exported Variables:
To see all exported variables, you can use:export -p
Use Cases:
- Setting paths for applications (e.g.,
PATH,JAVA_HOME). - Configuring environment settings for scripts or applications.
If you have more questions or need examples, feel free to ask!
