/var/tmp/exercise-two/Alice/likes/an-ox <---- a file /var/tmp/exercise-two/Emily/has-bought/a-horse <---- a file /var/tmp/exercise-two/Gary/has-bought/a-rhino <---- a directory /var/tmp/exercise-two/Gary/has-bought/a-rhino/less <---- a file /var/tmp/exercise-two/Gary/has-bought/a-rhino/is <---- a file /var/tmp/exercise-two/Gary/has-bought/a-rhino/more <---- a file /var/tmp/exercise-two/Mary/is/a-snake <---- a file則在你的 exer2 下建立如下對應的結構.
~/unix-1081/exer2/ |---Alice/ | `---likes/ | `---an-ox |---Emily/ | `---has-bought/ | `---a-horse |---Gary/ | `---has-bought/ | `---a-rhino/ | |---is | |---less | `---more `---Mary/ `---is/ `---a-snake注意: 若是檔案的話, 內容必須一樣, 也就是說要用複製的.
$ cat F1 12 34 11 $ cat F2 -4 33 78 23 40 $ ./ex5.sh F1 # read from F1 max is 34 min is 11 avg is 19.00 $ ./ex5.sh F2 # read from F2 max is 78 min is -4 avg is 34.00 $ ./ex5.sh F1 F2 # read from F1 and F2 max is 78 min is -4 avg is 28.37 $ ./ex5.sh # read from stdin 10 20 -9 max is 20 min is -9 avg is 7.00 $
$ showdir /var/tmp/ex6-dir/ ex6-dir/ |---D/ | `---e --> ../c |---E/ | |---baga | `---me |---a |---b |---c |---cat/ | `---dg/ `---klim $ tree -F /var/tmp/ex6-dir/ /var/tmp/ex6-dir/ |-- D/ | `-- e -> ../c |-- E/ | |-- baga | `-- me |-- a |-- b |-- c |-- cat/ | `-- dg/ `-- klim 4 directories, 7 files $
$ cat ex7-k1 klim 10 20 milk 199 joe 20 # klim is appeared again! oak 100 red 200 10 klim 30 joe 199 marry 20 julie 2000 #joe joe $ ./ex7.awk < ex7-k1 klim = 20.00 milk = 199.00 oak = 100.00 red = 105.00 joe = 109.50 marry = 20.00 julie = 2000.00 $
$ cat IN-data-11 This is klim speaking. klim is good, klim is healthy, and klim is not milk. Haha, it is funny. $ cat IN-pat-11 # Each line is composed of two strings as the following shows. klim toostrong milk klim toostrong milk $ cat IN-data-11 | ./ex11.sh ./ex11.sh pattern-file $ cat IN-data-11 | ./ex11.sh IN-pat-11 This is milk speaking. milk is good, milk is healthy, and milk is not klim. $
if $1 not exist then exit Use awk to generate the scripts for grep and sed invoke grep and sed, reading from stdin, sending output to stdout remove temporary files