🖥
Bash — 全ての変数の一覧を表示する ( $ declare -p )
例
$ declare -p
declare -x Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.qwKNOoccQA/Render"
declare -- BASH="/usr/local/bin/bash"
declare -r BASHOPTS="cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath"
declare -ir BASHPID
declare -A BASH_ALIASES=()
declare -a BASH_ARGC=()
declare -a BASH_ARGV=()
declare -A BASH_CMDS=()
declare -- BASH_COMMAND
declare -a BASH_LINENO=()
declare -a BASH_SOURCE=()
declare -- BASH_SUBSHELL
declare -ar BASH_VERSINFO=([0]="4" [1]="4" [2]="23" [3]="1" [4]="release" [5]="x86_64-apple-darwin17.5.0")
declare -- BASH_VERSION="4.4.23(1)-release"
declare -x COLORFGBG="7;0"
declare -x COLORTERM="truecolor"
declare -- COLUMNS="74"
declare -- COMP_WORDBREAKS
declare -x CPATH="/usr/local/opt/openssl/include:/usr/local/opt/openssl/lib:"
declare -a DIRSTACK=()
declare -x EDITOR="vim"
declare -ir EUID="501"
declare -x FPATH="/Users/yuma/.zsh/autoload/:/usr/local/share/zsh/site-functions:/usr/local/Cellar/zsh/5.5.1/share/zsh/functions"
declare -a FUNCNAME
declare -a GROUPS=()
declare -i HISTCMD
declare -- HISTFILE="/Users/yuma/.bash_history"
declare -- HISTFILESIZE="500"
declare -- HISTSIZE="500"
declare -x HOME="/Users/yuma"
declare -- HOSTNAME="yinaura.local"
declare -- HOSTTYPE="x86_64"
declare -- IFS="
"
declare -x ITERM_PROFILE="Default"
declare -x ITERM_SESSION_ID="w0t3p1:FD28551F-0109-438D-B3E9-1F636FF4B578"
declare -x LANG="en_US.UTF-8"
declare -x LC_CTYPE="UTF-8"
declare -x LD_LIBRARY_PATH="/usr/local/opt/openssl/lib:"
declare -i LINENO
declare -- LINES="33"
declare -x LOGNAME="yuma"
declare -x LSCOLORS="gxfxbxdxcxegedabagacad"
declare -- MACHTYPE="x86_64-apple-darwin17.5.0"
declare -i MAILCHECK="60"
declare -x OLDPWD="/Users/yuma/tmp"
declare -- OPTERR="1"
declare -i OPTIND="1"
declare -- OSTYPE="darwin17.5.0"
declare -x PATH="/Users/yuma/.rbenv/shims:/Users/yuma/.rbenv/bin:/Users/yuma/.gitim:/Users/yuma/.rbenv/shims:/Users/yuma/.rbenv/bin:./vendor/bin:/Users/yinaura/google-cloud-sdk/bin:/usr/local/opt/openssl/bin:/Users/yuma/eco/bin:/Users/yuma/.gitim/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
declare -a PIPESTATUS=([0]="0" [1]="127")
declare -ir PPID="46201"
declare -- PS1="\$ "
declare -- PS2="> "
declare -- PS4="+ "
declare -x PWD="/Users/yuma"
declare -i RANDOM
declare -x RBENV_SHELL="bash"
declare -- SECONDS
declare -x SHELL="/usr/local/bin/zsh"
declare -r SHELLOPTS="braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor"
declare -x SHLVL="2"
declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.cYRwmMMtTf/Listeners"
declare -x TERM="xterm-256color"
declare -x TERM_PROGRAM="iTerm.app"
declare -x TERM_PROGRAM_VERSION="3.2.0"
declare -x TERM_SESSION_ID="w0t3p1:FD28551F-0109-438D-B3E9-1F636FF4B578"
declare -x TMPDIR="/var/folders/fp/7jxb8qwx3xsdwy683lm_4q4r0000gn/T/"
declare -ir UID="501"
declare -x USER="yuma"
declare -x XPC_FLAGS="0x0"
declare -x XPC_SERVICE_NAME="0"
declare -- _=""
declare -x __CF_USER_TEXT_ENCODING="0x1F5:0x0:0x0"
ヘルプ
If no names are given, then `declare' will display the values of variables instead.
declare
Declare variables and give them attributes.
SYNTAX
declare [-afFrxi] [-p] [name[=value]]
OPTIONS
-a Each name is an array variable.
-f Use function names only.
-F Inhibit the display of function definitions;
only the function name and attributes are printed.
(implies -f)
-i The variable is to be treated as an integer;
arithmetic evaluation is performed when the
variable is assigned a value.
-p Display the attributes and values of each name.
When `-p' is used, additional options are ignored.
-r Make names readonly. These names cannot then
be assigned values by subsequent assignment statements
or unset.
-x Mark each name for export to subsequent commands
via the environment.
If no names are given, then `declare' will display the values of variables instead.
declare Man Page - Bash - SS64.com
参考
- Typing variables: declare or typeset
- command line - How to list all variables names and their current values? - Ask Ubuntu
バージョン
- bash 4.2
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2018-09-05
Discussion