20150913-15 Jobs
1. Describe the operation principle of shell program (can be attached with necessary graphic instructions)
Shell Script Foundation Advanced (i)----shell introduction
2, summarize all the knowledge points involved in shell programming (such as: variables, syntax, command status, etc., to take the picture of Yo)
Shell Script basis Advanced (ii)----variables and operators
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")
Shell Script Foundation Advanced (iii)----Process Control statements
4. Summarize the usage of the Text Processing tool sed and awk (must accompany the example)
5. Write a script: If a path does not exist, it is created as a directory; otherwise it is present and the content type is displayed; (Don't doubt it's that simple)
Shell Script Foundation Advanced (iii)----Process Control Statements Exercise 1
Modified version: Allows users to customize the path
#!/bin/bash#if [-E $];then echo "$ exists." File $1else mkdir-p $1fi
6, write a script to complete the following functions; Judging the given two values, which is the big or small; the method of the given number: script parameter, command interaction; (still so simple using read)
Shell Script Foundation Advanced (iii)----Process Control statements Exercise 5
Command interaction:
#!/bin/bash#read -p "Plz input two integer:" -t 10 num1 num2if [ -z $num 1 ]| | [ -z $num 2 ];then echo "your input parameters are Less than 2.plz re-enter. " exit 1fiif [[ $num 1 =~ ^[0-9]+$ ]]&&[[ $num 2 =~ ^[0-9]+$ ]];then if [ $num 1 -gt $num 2 ];then echo "the max number is $num 1." echo "the min number is $num 2." else echo "the max number is $num 2." echo "the min number is $num 1." fielse echo "the number $num 1 or $num 2 is not a integeR.at least have a string. " Fi
7, the sum of all the odd numbers within 100 (at least 3 methods. Yes, this is our assignment. ^_^)
Method One:
#!/bin/bashdeclare-i sumfor i in {1..100};d o if [$[$i%2]-eq 1];then sum+= $i Fidoneecho $sum
Method Two:
#!/bin/bashdeclare-i sumfor i in ' seq 1 2 ';d o sum+= $idoneecho $sum
Method Three:
#!/bin/bash#declare-i sumdeclare-i I=1while [$i-lt 101];d o sum+= $i i+=2doneecho $sum
8, write a script to achieve the following functions: (1) to pass two text file path to the script, (2) display two files with a large number of blank lines and the number of blank lines, (3) display two files in a large number of files and their total number of rows;
Shell Script Foundation Advanced (iii)----Process Control Statements Exercise 9
9, write a script (1) Prompts the user to enter a string, (2) Judge: If the input is quit, the script is exited, otherwise, the input string content is displayed;
#!/bin/bash#read-p "plz enter a string:"-T ten strif [$STR = = quit];then exit 1else Echo $strfi
10, write a script, print 2^n table; n equals the value entered by a user; (Sorry, I'm naughty)
#!/bin/bash#read -t 5 -p "Please enter a integer: " nif [ -z $n ]| | [ $n -lt 0 ];then echo "Your enter is error." Elsecount=2 for ((i=0;i<= $n; i++));d o if [ $i -eq 0 ]; then echo -e "1" elif [ $i -eq 1 ];then echo -e "2" elif [ $i -gt 1 ];then count+=x2 echo $count =$[2** $i] fidonefi
11, write a script, write a few functions: function 1, achieve the sum of two values given; function 2, The greatest common divisor of the given two values, the function 3, the least common multiple of the given two values, and the size of the selected and two numeric values of the function are provided through interactive input.
#!/bin/bash#read -p "Plz enter two integer:" -t 20 num1 num2if [ -z $num 1 ]| | [ -z $num 2 ];then echo "your enter is error.plz enter Two integer. " exit 1fisum () {declare -i sumsum=$[$num 1+ $num 2] #echo "the sum of two integer is $sum. "} GCD () {while [ $num 1 != $num 2 ];d oif [ $num 1 -gt $num 2 ];then poor=$[$num 1-$num 2] num1= $poor elif [ $num 2 -gt $num 1 ];then poor=$[$num 2-$num 1] num2= $poorfidone #echo "the gcd of two integer is $poor. " return $poor}LCM () {pro=$[$num 1* $num 2]while [ $num 1 != $num 2 ];d oif [ $num 1 -gt $num 2 ];then poor=$[$num 1-$num 2] num1= $poor elif [ $num 2 -gt $num 1 ];then poor=$[$num 2-$num 1] num2=$ poorfidonelcm=$[$pro/$poor]}case $1 in sum) sum echo " the sum of two integer is $sum. " ;; &NBSP;GCD) GCD echo "The gcd of two integer is $poor. " ;; &NBSP;LCM) LCM echo "The lcm of two integer is $LCM. " ;; *) echo "USAGE:$0&NBSP;SUM|GCD|LCM" exit 1esac
This article is from the "Start Again" blog, please be sure to keep this source http://4708705.blog.51cto.com/4698705/1698319
Shell Script Foundation Advanced (iv)----job