/var/tmp/exercise-two/Bob/has-bought/a-cow /var/tmp/exercise-two/Bob/has-bought/a-deer /var/tmp/exercise-two/Bob/has-bought/a-dog /var/tmp/exercise-two/David/is/a-tiger /var/tmp/exercise-two/David/is/a-tiger/fun /var/tmp/exercise-two/David/is/a-tiger/is /var/tmp/exercise-two/David/is/a-tiger/it則在你的 exer2 下建立如下對應的結構.
~/unix-1122/exer2
|---Bob
| `---has-bought
| |---a-cow
| |---a-deer
| `---a-dog
`---David
`---is
`---a-tiger
|---fun
|---is
`---it
$ ./ex6-sum.sh 1 2 # number of argument != 3
usage: a b step
$ ./ex6-sum.sh # number of argument != 3
usage: a b step
$ ./ex6-sum.sh 1 2 3 # 1,4,7 ... ==> 1
1
$ ./ex6-sum.sh 1 2 1 # 1,2,3 ... ==> 1+2 = 3
3
$ ./ex6-sum.sh -10 -3 2 # -10,-8,... ==> -10-8... = -28
-28
$ ./ex6-sum.sh -10 -3 1
-52
$ ./ex6-sum.sh -10 -3 4 # -10,-6,-2,2,... ==> -10-6= -16
-16
$ ./ex6-sum.sh 10 -3 2 # 10 > -3, so 0
0
$ ./ex6-sum.sh 10 -3 -2 # 10,8,6,...-2,-4,.. ==> 10+8+...-2 = 28
28
$ ./ex6-sum.sh 10 -3 -4 # 10,6,2,-2,-6... ==> 10+6+2-2 = 16
16
$ ./ex6-sum.sh 10 -3 -6
12
$
$ ./ex7-extract.sh
usage: ./ex7-extract.sh keyword [file] ....
$ ./ex7-extract.sh klim
OK it is not klim
milk is milk
klim got $1000
$1000 OK got is it not <----- ctrl-D pressed
$
$ cat IN-a
oak is not klim
klim is good
ok it is fine
$
$ cat IN-b
192390 klim
klim tooyoung
ok it is fine
$
$ ./ex7-extract.sh klim IN-a
good is is not oak
$
$ ./ex7-extract.sh klim IN-a IN-b
192390 good is is not oak tooyoung
$
$ seq 1 100 | ./ex8.sh
$ seq 1 100 | ./ex8.sh 1 9
1
9
$ seq 1 100 | ./ex8.sh 1 12 34-35 77-80
1
12
34
35
77
78
79
80
$
$
$ cat IN-9
# oak
100 23 11 44
-99 10
# klim
1000 20 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# baga
-100 -20
$
$
$ ./ex9.awk IN-9
oak 89
klim 1233
baga -120
$
$
$ cat IN-10
# this is a comment
joejoejoe 10 20 30 #this is also a comment
OAK -999 10 # 10000
joeJOE 2000
oak 10
milk 1000 # 2000
$ ./ex10.awk IN-10
OAK = -326.33
MILK = 1000.00
JOEJOE = 515.00
$