export command in Linux with Examples
export is bash shell BUILTINS commands, which means it is part of the shell. It marks an environment variables to be exported to child-processes.
Export is defined in POSIX as The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to the word.
In simple terms, environment variables are set when you open a new shell session. at any time if you change any of the variable values, the shell has no way of picking that change. The export command, on the other hand, provides the ability to update the current shell session about the change you made to the exported variable. You don’t have to wait until new shell session to use the value of the variable you changed.
Syntax :
export [-f] [-n] [name[=value] ...] or export -p
Options of export command
1. Without any argument : To view all the exported variables.
EXAMPLE :

2. -p : To view all exported variables on current shell.
SYNTAX :
$ export -p
EXAMPLE :

3. -f: It must be used if the names refer to functions. If -f is not used, the export will assume the names are variables.
SYNTAX :
$ export -f function_name
EXAMPLE : To export shell function:

Note: Bash command is used for showing that in the child shell, the shell function got exported.
4. name[=value]: You can assign value before exporting using the following syntax.
SYNTAX :
$ export name[=value]
EXAMPLE : To set vim as a text editor

Note: No output will be seen on screen, to see exported variable grep from exported ones is used.
5. -n: Named variables (or functions, with -f) will no longer be exported.
SYNTAX :
$ export -n variable_name
EXAMPLE :

Note: No output will be seen on screen, to see exported variable grep from exported ones is used.
Recommended Posts:
- more command in Linux with Examples
- ln command in Linux with Examples
- w command in Linux with Examples
- apt-get command in Linux with Examples
- df Command in Linux with examples
- man command in Linux with Examples
- cc command in Linux with Examples
- which command in Linux with examples
- cp command in Linux with examples
- rev command in Linux with Examples
- sum command in Linux with Examples
- bg command in Linux with Examples
- fg command in Linux with examples
- tty command in Linux with examples
- cvs command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



