Linux / Unix: Bash Shell See All Exported Variables and Functions

How do I see a list of all exported variables and functions under Unix bash shell?

The export command makes your local variables global. The syntax is as follows:

export PATH=$PATH:/usr/local/bin:~/bin
export EDITOR=/usr/local/bin/vim
export SHELL=/bin/ksh
export LANG=En_US
export PAGER=/usr/local/bin/most

To make your local shell variables global automatically, export them in your ~/.profile or ~/.bash_profile file under Unix like operating systems. To see a list of all exported variables and functions pass the -p option to the export command:

export -p
export -p | grep  something
export -p | less
export -p | more

Sample outputs:

DISPLAY=unix:0
EDITOR=vim
HISTFILE=/home/vivek/.bash_history
HISTSIZE=1000
HOME=/home/vivek
LANG=En_IN
LOGNAME=vivek
MAIL=/usr/mail/vivek
MAILCHECK=0
PWD=/home/vivek
SHELL=/bin/bash

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.