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