Variable assignment for shell scripts

Source: Internet
Author: User

Parameter related knowledge
${parameter:-word}: If parameter is empty or undefined, the variable is expanded to "word"; otherwise, the value of parameter is expanded; ${parameter:+word}: If parameter is empty or undefined, do nothing; otherwise, expand to "word" value; ${parameter:=word}: If parameter is empty or undefined, the variable is expanded to Word and the expanded value is assigned to Parameter;${parameter : Offset}${parameter:offset:length}: Take a substring, starting at offset at the next character, take lenth long substring;-[[Email protected] etc]# a=3 [[email& Nbsp;protected] etc]# Echo ${a:-30} 3 [[email protected] etc]# unset A [[email protected] etc]# Echo ${ A:-30} [[email protected] etc]# echo $a + [[email protected] etc]# echo $a #结果为空 [[email  Protected] etc]# echo ${a:+30} #结果为空 [[email protected] etc]# a=1 [[email protected] etc]# Echo ${a:+30 } 30= [[email protected] etc]# echo $a 1 [[email protected] etc]# Echo ${a:=30} 1 [[Email&nbs    P;protected] etc]# echo $a 1 [[email protected] etc]# unset A [[email protected] etc]# Echo ${a:=30} [[email protected] etc]# echo $a 30 variable assignment relatedcontent [[email protected] etc]# a= "Hello World" [[email protected] etc]# Echo ${a:2:3} llo [[email  Protected] etc]# echo ${a:2} Llo World

Variable assignment for shell scripts

Related Article

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.