Bash command line return values and expand

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.