builtin
[!TIP|label:references:]
eval
example
without
eval:with
eval:or with
bash -c
example
${BASH_SOURCE[0]}
Path to the source file where the current script or function definition resides
${FUNCNAME[0]}
Name of the currently executing function
${LINENO}
Current line number within the script or function where this variable is referenced
${BASH_VERSION}
Version string of the running Bash interpreter
${BASH_LINENO[@]}
Line numbers of each function call in the call stack
${BASH_ARGV[@]}
All passed arguments (in reverse order)
${BASH_ARGC[@]}
Number of arguments received by each function in the call stack
to check the script is been sourced or run directly
PS4
[!NOTE]
main.sh


[!NOTE]reference:
History Expansion | Event Designators
!!: to repeat last commands
set +Horset +o histexpandto disable
set -Horset -o histexpandto enablemore via
$ man bash | less -Ip 'Event Designators'set
example
-a
-o allexport
-b
cause the status of terminated background jobs to be reported immediately
-e
-o errexit
Exit immediately if a pipeline returns a non-zero status
-f
Disable filename expansion (globbing)
-h
-o hashall
-k
-o keyword
-m
-o monitor
-n
-o noexec
-o option-name
see option name
-p
-o privileged
the $BASH_ENV and $ENV files are not processed
-t
-o onecmd
-u
-o unset
treat unset variables and parameters other than the special parameters '@' or '*' as an error
-v
verbose. print shell input lines as they are read
-x
-o xtrace
[debug] print commands and their arguments as they are executed
-B
-o braceexpand
shell will perform brace expansion
-c
-o noclobber
prevent output redirection using '>', '>&', and '<>' from overwriting existing files.
-E
-o errtrace
-H
-o histexpand
-P
do not resolve symbolic links
-T
-o functrace
any trap on DEBUG and RETURN are inherited by shell functions
--
if no arguments follow this option, then the positional parameters are unset
-
signal the end of options, cause all remaining arguments to be assigned to the positional parameters
show current status
show on/off
show +o/-o
option name
allexport
Same as -a.
braceexpand
Same as -B.
emacs
Use an emacs-style line editing interface.
This also affects the editing interface used for read -e.
errexit
Same as -e.
errtrace
Same as -E.
functrace
Same as -T.
hashall
Same as -h.
histexpand
Same as -H.
history
Enable command history, as described in Bash History Facilities. This option is on by default in interactive shells.
ignoreeof
An interactive shell will not exit upon reading EOF.
keyword
Same as -k.
monitor
Same as -m.
noclobber
Same as -C.
noexec
Same as -n.
noglob
Same as -f.
nolog
Currently ignored.
notify
Same as -b.
nounset
Same as -u.
onecmd
Same as -t.
physical
Same as -P.
pipefail
If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.
posix
Change the behavior of Bash where the default operation differs from the POSIX standard to match the standard (see Bash POSIX Mode). This is intended to make Bash behave as a strict superset of that standard.
privileged
Same as -p.
verbose
Same as -v.
vi
Use a vi-style line editing interface. This also affects the editing interface used for read -e.
xtrace
Same as -x.
[!TIP|label:tips:]
iMarslo : filename expansion check the shopt on/off (
set +o)off
on
check without output via
-q
on
off
-s
enable ( [s]et )
-u
disable ( [u]nset )
-q
suppresses normal output
-o
set -o
options
assoc_expand_onceautocdcdable_varscdspellcheckhashcheckjobscheckwinsizecmdhistcompat31compat32compat40compat41compat42compat43compat44complete_fullquotedirexpanddirspelldotglob-s:*will including all.*
execfailexpand_aliasesextdebugextglobextquotefailglob-s: show error msg and cmd not been exectued
force_fignoreglobasciirangesglobstargnu_errfmthistappendhistreedithistverifyhostcompletehuponexitinherit_errexitinteractive_commentslastpipelithistlocalvar_inheritlocalvar_unsetlogin_shellmailwarnno_empty_cmd_completionnocaseglobnocasematchnullglobprogcompprogcomp_aliaspromptvarsrestricted_shellshift_verbosesourcepathxpg_echo
examples
show all status
show single option
[!NOTE|label:references:]
\C-
control prefix
\M-
meta prefix
\e
an escape character
\\
backslash
\"
", a double quotation mark
\'
', a single quote or apostrophe
\a
alert (bell)
\b
backspace
\d
delete
\f
form feed
newline
carriage return
horizontal tab
\v
vertical tab
\nnn
octal value
\xHH
hexadecimal value
more samples
"\e[11~":ESC [ 1 1 ~’: "Function Key 1"keyname
keyseq
alt-.
-
last arg from previous command
alt-d
^[dw
delete the next word on the line
alt-backspace
^[db
delete backwards one word
ctrl-w
^[dT
delete backwards a whole word until white space/punctuation
ctrl-k
^[D
delete from the cursor to the end of the line
ctrl-u
^[d^
delete from the cursor to the start of the line
alt-f
^[E
move to the end of the word
alt-b
^[w
move to the start of the word
ctrl-e
^[$
move to the very end of the line
ctrl-a
^[^
move to the very start of the line
vi mode
[!NOTE]
hybrid mode
[!TIP|label:references:]
[!NOTE|label🎶] This is a patched version of bash
4.3.48that adds support for custom prompt mode indicators. It also adds support for a\mprompt escape to specify where in the prompt the indicator should occur.
0
blinking block
1
blinking block (default)
2
steady block
3
blinking underline
4
steady underline
5
blinking bar (xterm)
6
steady bar (xterm)


[!NOTE|label:references:]

bash show-mode-in-prompte change cursor shape
PS1
[!NOTE|label:see also:]
inputrc

show options
options
active-region-start-coloractive-region-end-colorbell-stylebind-tty-special-charsblink-matching-parencolored-completion-prefixcolored-statscomment-begincompletion-display-widthcompletion-ignore-casecompletion-map-casecompletion-prefix-display-lengthcompletion-query-itemsconvert-metadisable-completionecho-control-charactersediting-modeemacs-mode-stringenable-active-regionenable-bracketed-pasteenable-keypadenable-meta-keyexpand-tildehistory-preserve-pointhistory-sizehorizontal-scroll-modeinput-metaisearch-terminatorskeymapkeyseq-timeoutmark-directoriesmark-modified-linesmark-symlinked-directoriesmatch-hidden-filesmenu-complete-display-prefixoutput-metapage-completionsprint-completions-horizontallyrevert-all-at-newlineshow-all-if-ambiguousshow-all-if-unmodifiedshow-mode-in-promptskip-completed-textvi-cmd-mode-stringvi-ins-mode-stringvisible-stats
key bindings

list all names
inputrc
inputrcunbind
[!NOTE]
tips
glob-list-expansionsupcase-word&&downcase-word&&capitalize-word
test
[!NOTE|label:references:]
-a <FILE>
True if exists. (* not recommended, may collide with -a for AND)
-e <FILE>
True if exists.
-f <FILE>
True, if exists and is a regular file.
-d <FILE>
True, if exists and is a directory.
-c <FILE>
True, if exists and is a character special file.
-b <FILE>
True, if exists and is a block special file.
-p <FILE>
True, if exists and is a named pipe (FIFO).
-S <FILE>
True, if exists and is a socket file.
-L <FILE>
True, if exists and is a symbolic link.
-h <FILE>
True, if exists and is a symbolic link.
-g <FILE>
True, if exists and has sgid bit set.
-u <FILE>
True, if exists and has suid bit set.
-r <FILE>
True, if exists and is readable.
-w <FILE>
True, if exists and is writable.
-x <FILE>
True, if exists and is executable.
-s <FILE>
True, if exists and has size bigger than 0 (not empty).
-t <fd>
True, if file descriptor is open and refers to a terminal.
<FILE1> -nt <FILE2>
True, if is newer than (mtime).
<FILE1> -ot <FILE2>
True, if is older than (mtime).
<FILE1> -ef <FILE2>
True, if and refer to the same device and inode numbers.
Last updated
Was this helpful?