September 13, 2015 Course assignments-Questions about the shell

Source: Internet
Author: User

1. Describe the operation principle of shell program (can be attached with necessary graphic instructions);

s


after system kernel execution.

2, summarize all the knowledge points involved in shell programming (such as: variables, grammar, command status, etc., to take the picture of Yo);


The following instance is from Iredmail's installation script tmprootdir= "$ (dirname $0)"   //defines the temp directory, which is the variable in the shell Echo ${tmprootdir}  | grep  ' ^/'  >/dev/null 2>&1if [ x "$?"  == x "0"  ]; then   //determine whether to perform     export based on the last command state above  rootdir= "${tmprootdir}"   //uses both the command state and the If Judgment else    export rootdir= "$ ( PWD) "fi# create ssl/tls cert file.check_status_before_run generate_ssl_keys   //check_status_before_run is a function # The following is the definition of this function check_status_before_run () {    # if  function was successfully executed, this function will write one  line    # in  $STATUS _file:    #     #   export status_[function_name]= ' Done '     #     function_name= "${1}"   //use positional parameters to get variable values  &NBSp;  function_status_name= "Status_${function_name}"     function_status_value= "$ ( Eval echo \$${function_status_name}) "    if [ x" ${function_status_ Value} " == x" Done " ]; then        ECHO_SKIP " Function: $1. "     else         $function _name          #if  [ x "$?"  == x ' 0 '  ]; then        #     echo  "export ${function_status_name}= ' Done '"  >> ${STATUS_FILE}          #fi     fi} #另一个函数的定义 with a For loop, if Judgment Backup_file () {     # Usage: backup_file file1 [file2 file3 ... fileN]     if [ x "$#"  != x "0"  ]; then   //$#  the number of arguments added to the shell         for conf_ file in [email protected]; do  //using a For loop to read the configuration file,             if [ -f ${conf_file} ]; then                 if [ x "${ Iredmail_debug} " == x" Yes " ]; then                     echo -e  "${_backup_flag} ${ conf_file} -> $ (Basename ${conf_file}). ${date}. "                 fi                 cp -f ${conf_ File} ${conf_file}.${date}            else                 :            fi         done    else         :    FI}




3, summarize the course of all the circular statement, the use of conditional judgment and related examples; (if (jpg|png is not exist); echo "You say a XX")






September 13, 2015 Course assignments-Questions about the shell

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.