Shell commands used in a development

Source: Internet
Author: User

1. Time Calculation

Starttime= 'Date+'%y-%m-%d%h:%m:%s''; Endtime=`Date+'%y-%m-%d%h:%m:%s''; Start_seconds=$(Date--Date="$starttime"+%s); End_seconds=$(Date--Date="$endtime"+%s);EchoEnd_seconds-start_seconds

2. Get the status code returned by the link

Checkurl='http://www.baidu.com'1 -S-w"%{http _code}" -o temp  ${checkurl}

3.while...do,for cycle; condition to determine if; Exit program exit

 while(' Curl--connect-timeout1-S-W "%{http_code}"-O temp ${checkurl} '! =' $' )) Do             forIinch$(seq 1  -); Do Echo 'sleep countdown to wait URL is ok:'$(( --$i));Sleep 1; Done;//Countdown Endtime=`Date+'%y-%m-%d%h:%m:%s'`; Start_seconds=$(Date--Date="$starttime"+%s); End_seconds=$(Date--Date="$endtime"+%s); if[[$ (end_seconds-start_seconds)] > -]]; ThenExit1            fi    
Done

4. String interception and substitution

checkurl=${line#*=}    // intercept variable line, reserved checkurl=${checkurl/\$\{esmhost\}/sss to the right of equal sign }   //  Replace ${esmhost} in Checkurl with SSS

5. String substitution for text files

All ABC in the file is replaced by AAAAA

sed ' s#abc#aaaaa#g ' ./docker-compose.yml

6. Fuzzy Matching

If the variable contains the string ' Register.node.checkurl '

if ' Register.node.checkurl [ ]];  Then fi

Shell commands used in a development

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.