跳到主內容

【shell】內建變數

$BASH_ENV  absolute path of startup file
$CDPATH  directories searched by cd
$FCEDIT  absolute path of history editor
$HISTCMD  the history number of the current command
$HISFILE  absolute path of history file
$HISTSIZE  number of remembered commands
$HOME  login directory
$IFS  token delimiters
$LINENO  current line number in shell script
$LINES  terminal height
$MAIL  absolute path of mailbox
$MAILCHECK  number of seconds to check mail
$OLDPWD  absolute path of previous directory
$OPTARG  option set by getopt
$OPTIND  option's ordinal position set by getopt
$OSTYPE  the OS on which bash is executing
$PATH  command search path
$PPID  process ID of parent
$PS1  primary prompt
$PS2  secondary prompt
$PWD  absolute path of current directory
$RANDOM  random integer
$REPLY  default variable for read
$SECONDS  number of seconds since shell started
$SHELL  absolute pathname of preferred shell
$TMOUT  seconds to log out after lack of use
$UID  user ID of the current user
$$  process ID of current shell
$?  exit status of most recent statement
$#  參數的數目
$*  代表所有參數
$!  PID of the most recently started backgroup job