ihtkwot
ihtkwot

Reputation: 1252

Are there any UNIX environment variables longer than four characters?

I know there is $USER, $HOME, $PATH, etc.

Upvotes: 0

Views: 246

Answers (8)

Kalanidhi
Kalanidhi

Reputation: 5092

env | cut -d = -f 1 | grep -E "([A-Z_]{4,})"

Use this command

Upvotes: 1

David Newcomb
David Newcomb

Reputation: 10943

Every system is configured differently so rather than listing them all here, just enter the following command to list them all on your own system:

set | sed 's/=.*//' | grep -v "^[A-Z_]\{4\}$"

I'd use set instead of env as it has greater scope. Most system environment variables are in upper case so to add that restriction add an extra grep to the pipe line.

set | sed 's/=.*//' | grep "[A-Z_]" | grep -v "^[A-Z_]\{4\}$"

Upvotes: 1

Nate W.
Nate W.

Reputation: 9249

There are plenty: DBUS_SESSION_BUS_ADDRESS, XAUTHORITY, GDM_LANG, etc. You can view all your environment variables with the env command - type it in inside a terminal.

As far as I know, there's no limitations on environment variables, they can be of any length, and anything can create them and add them to the environment (using export, as you may have seen). Conceptually, environment variables act as "global variables" that are shared among all programs running in a terminal.

Upvotes: 8

Glenn McAllister
Glenn McAllister

Reputation: 1823

Err... lots?

$ env | cut -d = -f 1 | sort | uniq 
_
COLORFGBG
DBUS_SESSION_BUS_ADDRESS
DESKTOP_SESSION
DISPLAY
DM_CONTROL
EDITOR
GPG_AGENT_INFO
GS_LIB
GTK2_RC_FILES
GTK_RC_FILES
HISTCONTROL
HOME
KDE_FULL_SESSION
KDE_MULTIHEAD
KDE_SESSION_UID
KDE_SESSION_VERSION
KONSOLE_DBUS_SERVICE
KONSOLE_DBUS_SESSION
LANG
LANGUAGE
LESSCLOSE
LESSOPEN
LIBGL_DRIVERS_PATH
LOGNAME
LS_COLORS
OLDPWD
PATH
PROFILEHOME
PWD
QT_PLUGIN_PATH
SESSION_MANAGER
SHELL
SHLVL
SSH_AGENT_PID
SSH_AUTH_SOCK
TERM
USER
WINDOWID
WINDOWPATH
XCURSOR_THEME
XDG_DATA_DIRS
XDG_SESSION_COOKIE
XDM_MANAGED

Upvotes: 7

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84189

How about $DISPLAY and $LD_LIBRARY_PATH.

Upvotes: 1

Sonny Saluja
Sonny Saluja

Reputation: 7287

User defined environment variables don't have to four characters long (ex. CLASSPATH)

Upvotes: 0

chrisaycock
chrisaycock

Reputation: 37930

$LD_LIBRARY_PATH and $LD_PRELOAD both exist for linking.

Upvotes: 0

Kaleb Brasee
Kaleb Brasee

Reputation: 51955

Yep, $SHELL is one of them that I know of.

Edit: see this page for more of them.

Upvotes: 3

Related Questions