Bash command-line return values and expand Bash command State return 1. Command status results and execution results
(1) The status return value of the command execution, after the command execution completes, its execution status result value is saved in Bash's special state variable $?
0: Success
1-255: Failure
[Root@yumc66~]# Date .Years AMonth -Day Tuesday One: $:TenCst[root@yumc66~]# echo $?0[Root@yumc66~]# $?-Bash:0: command notFound[root@yumc66~]# echo $?127
(2) Command return value (execution result)
command return value, depending on the command and its function, the results are different.
command return value (execution result) reference
$(COMMAND)或`COMMAND`$(date +%H-%M-%S)
2. Command line expansion
~: Automatically expands to the user's home directory, or specifies the user's home directory
{}: A grouping mechanism that can host a comma-separated list of paths and expand them to multiple paths
For example 1
~]# ls /tmp/{a,b} 相当于 ls /tmp/a /tmp/b
For example 2 Create/tmp/x/y1,/tmp/x/y2,/tmp/x/y1/a,/tmp/x/y1/b
~]#mkdir -pv /tmp/x/{y1/{a,b},y2}~]#tree /tmp/x 验证
For example 3 Create A_c,a_d,b_c,b_d
~]#mkdir -pv /tmp/{a/{c,d},b/{c,d}}或~]#mkdir /tmp/{a,b}_{c,d} -v 或 ~]#mkdir -v /tmp/{a,b}_{c,d} ~]#tree /tmp/a 验证
Bash command line return values and expand