开发者

Are there any UNIX environment variables longer than four characters?

I know there is $U开发者_如何学CSER, $HOME, $PATH, etc.


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.


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


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

Edit: see this page for more of them.


How about $DISPLAY and $LD_LIBRARY_PATH.


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\}$"


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

Use this command


$LD_LIBRARY_PATH and $LD_PRELOAD both exist for linking.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜