TOP Computer Languages


Special Parameters, Positional Parameters

man
*($*) is equivalent to "$1c$2c…", where c is the first character of the value of the IFS variable
@($@) is equivalent to "$1" "$2"
#($#) is the number of positional parameters in decimal
?($?) Expands to the exit status of the most recently executed foreground pipeline.
-($-) Expands to the current option flags
$($$) is the process ID of the shell
($!) is the process ID of the job most recently placed into the background
0($0) is the name of the shell or shell script
_($_) is the same as $0 in script, or the arguments of the last command.
int$1,$2,... are the Positional Parameters
TOC

Bourne Shell Variables

man
Parameter and Variable Index
CDPATH
HOME
IFSseparator characters
MAIL
MAILPATH
OPTARG
OPTIND
PATH
PS1primary prompt string'\s-\v\$ '
PS2secondary prompt string‘> ’
TOC

Bash Variables

man
Parameter and Variable Index
BASHThe full pathname Bash
BASHOPTSlist of shell optionscolon-separated
BASHPIDpidassoc.arr
BASH_ALIASESaliases
BASH_ARGCargcarr
BASH_ARGVargvarr
BASH_CMDScommandassoc.arr
BASH_COMMANDcurrent command
BASH_COMPATcompatibility level
BASH_ENVenv
BASH_EXECUTION_STRINGarg to -c
BASH_LINENOline no.arr
BASH_REMATCHrematcharr,ro
BASH_SOURCEsrc fnamearr
BASH_SUBSHELLsubshellint
BASH_VERSINFOversionarr,ro
BASH_VERSINFO[0]major versoin numberrelease
BASH_VERSINFO[1]minor version numberversion
BASH_VERSINFO[2]pathc level
BASH_VERSINFO[3]build
BASH_VERSINFO[4]release status(e.g., beta1)
BASH_VERSINFO[5]value of MACHTYPE
BASH_VERSIONversion number of current Bash
BASH_XTRACEFD-x trace file desc.
CHILD_MAX
COLUMNS
COMP_CWORD
COMP_LINE
COMP_POINT
COMP_TYPE
COMP_KEY
COMP_WORDBREAKS
COMP_WORDS
COMPREPLY
COPROC
DIRSTACK
EMACS
ENV
EUID
FCEDIT
FIGNORE
FUNCNAME
FUNCNEST
GLOBIGNORE
GROUPS
histchars
HISTCMD
HISTCONTROL
HISTFILE
HISTFILESIZE
HISTIGNORE
HISTSIZE
HISTTIMEFORMAT
HOSTFILE
HOSTNAME
HOSTTYPE
IGNOREEOF
INPUTRC
LANGlocale
LC_ALLoverride LANG,LC_
LC_COLLATE
LC_CTYPE
LC_MESSAGES
LC_NUMERIC
LINENO
LINES
MACHTYPE
MAILCHECK
MAPFILE
OLDPWD
OPTERR
OSTYPE
PIPESTATUS
POSIXLY_CORRECT
PPID
PROMPT_COMMAND
PROMPT_DIRTRIM
PS3
PS4
PWD
RANDOM
READLINE_LINE
READLINE_POINT
REPLY
SECONDS
SHELL
SHELLOPTS
SHLVL
TIMEFORMAT
TMOUT
TMPDIR
UID
TOC

One Liner

.bashrc

tips

Bash command line and input limit

for fork()/exec()
ARG_MAX:Maximum length of argument to the exec functions
$ getconf ARG_MAX
2097152

text colors

TOC

Prompt

PS1
#!/bin/bash
# bash text color samples

#ESCAPE \e color
echo $'\e[0m \\e[0;30m \e[0;30m black'
echo $'\e[0m \\e[0;31m \e[0;31m red'
echo $'\e[0m \\e[0;32m \e[0;32m green'
echo $'\e[0m \\e[0;33m \e[0;33m yellow'
echo $'\e[0m \\e[0;34m \e[0;34m blue'
echo $'\e[0m \\e[0;35m \e[0;35m magenta'
echo $'\e[0m \\e[0;36m \e[0;36m cyan'
echo $'\e[0m \\e[0;37m \e[0;37m light gray'
echo $'\e[0m \\e[1;30m \e[1;30m dark gray'
echo $'\e[0m \\e[1;31m \e[1;31m red'
echo $'\e[0m \\e[1;32m \e[1;32m green'
echo $'\e[0m \\e[1;33m \e[1;33m yellow'
echo $'\e[0m \\e[1;34m \e[1;34m blue'
echo $'\e[0m \\e[1;35m \e[1;35m magenta'
echo $'\e[0m \\e[1;36m \e[1;36m cyan'
echo $'\e[0m \\e[1;37m \e[1;37m white'
echo $'\e[0m \\e[0;40m \e[0;40m black'
echo $'\e[0m \\e[0;41m \e[0;41m red'
echo $'\e[0m \\e[0;42m \e[0;42m green'
echo $'\e[0m \\e[0;43m \e[0;43m yellow'
echo $'\e[0m \\e[0;44m \e[0;44m blue'
echo $'\e[0m \\e[0;45m \e[0;45m magenta'
echo $'\e[0m \\e[0;46m \e[0;46m cyan'
echo $'\e[0m \\e[0;47m \e[0;47m light gray'
echo $'\e[0m \\e[1;40m \e[1;40m dark gray'
echo $'\e[0m \\e[1;41m \e[1;41m red'
echo $'\e[0m \\e[1;42m \e[1;42m green'
echo $'\e[0m \\e[1;43m \e[1;43m yellow'
echo $'\e[0m \\e[1;44m \e[1;44m blue'
echo $'\e[0m \\e[1;45m \e[1;45m magenta'
echo $'\e[0m \\e[1;46m \e[1;46m cyan'
echo $'\e[0m \\e[1;47m \e[1;47m white'
echo $'\e[0m \\e[1:31m \\e[1;47m \e[0;31m \e[1;47m red on white'
echo $'\e[0m \\ep0m \e[0m reset'
TOC

shebang

#! /bin/bash
TOC

管理人/副管理人のみ編集できます