Skip to main content
added 22 characters in body
Source Link
todd_dsm
  • 317
  • 2
  • 9

MaybeI like simple things; this will work for POSIX systems:

printenv | sed 's;=.*;;' | sort
HOME
HOSTNAME
PATH
PWD
SHLVL
TERM

Maybe this will work for POSIX systems:

printenv | sed 's;=.*;;' | sort
HOME
HOSTNAME
PATH
PWD
SHLVL
TERM

I like simple things; this will work for POSIX systems:

printenv | sed 's;=.*;;' | sort
HOME
HOSTNAME
PATH
PWD
SHLVL
TERM
answered the question more specific to POSIX
Source Link
todd_dsm
  • 317
  • 2
  • 9

thanks to @greycat in the #bash IRC channel on freenode, the bash built-in: compgen -eMaybe this will print all environment variable nameswork for POSIX systems:

[root@957f5a5fc6deprintenv /]#| env
HOSTNAME=957f5a5fc6de
DISTTAG=f30container
PWD=/
FBR=f30
HOME=/root
LANG=C.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:...
FGC=f30
TERM=xterm
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env

Using the bash built-in:

[root@957f5a5fc6desed /]#'s;=.*;;' compgen| -e
DISTTAG
FBR
FGCsort
HOME
HOSTNAME
LANG
LS_COLORS
PATH
PWD
SHLVL
TERM

I'm mostly posting this so I don't forget it :-)

thanks to @greycat in the #bash IRC channel on freenode, the bash built-in: compgen -e will print all environment variable names:

[root@957f5a5fc6de /]# env
HOSTNAME=957f5a5fc6de
DISTTAG=f30container
PWD=/
FBR=f30
HOME=/root
LANG=C.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:...
FGC=f30
TERM=xterm
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env

Using the bash built-in:

[root@957f5a5fc6de /]# compgen -e
DISTTAG
FBR
FGC
HOME
HOSTNAME
LANG
LS_COLORS
PATH
PWD
SHLVL
TERM

I'm mostly posting this so I don't forget it :-)

Maybe this will work for POSIX systems:

printenv | sed 's;=.*;;' | sort
HOME
HOSTNAME
PATH
PWD
SHLVL
TERM
Source Link
todd_dsm
  • 317
  • 2
  • 9

thanks to @greycat in the #bash IRC channel on freenode, the bash built-in: compgen -e will print all environment variable names:

[root@957f5a5fc6de /]# env
HOSTNAME=957f5a5fc6de
DISTTAG=f30container
PWD=/
FBR=f30
HOME=/root
LANG=C.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:...
FGC=f30
TERM=xterm
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env

Using the bash built-in:

[root@957f5a5fc6de /]# compgen -e
DISTTAG
FBR
FGC
HOME
HOSTNAME
LANG
LS_COLORS
PATH
PWD
SHLVL
TERM

I'm mostly posting this so I don't forget it :-)