/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-1061/exer2/
|---Alice/
| `---likes/
| `---an-ox
|---Emily/
| `---has-bought/
| `---a-horse
|---Gary/
| `---has-bought/
| `---a-rhino/
| |---is
| |---less
| `---more
`---Mary/
`---is/
`---a-snake
注意: 若是檔案的話, 內容必須一樣, 也就是說要用複製的.
$ cat numbers
19
23
101
55
34
$ cat numbers | ./less-than 60
19
23
55
34
$ cat numbers | ./less-than 60 | ./greater-than 30
55
34
$
$ cat Numbers
6 7 8 9
10 11 12 13 14
129 37
8
119
$ cat Numbers | ./range 10 60
10
11
12
13
14
37
$ cat Numbers | ./range - 60
6
7
8
9
10
11
12
13
14
37
8
$ cat Numbers | ./range 200
$ cat Numbers | ./range 120
129
$ cat Numbers | ./range
6
7
8
9
10
11
12
13
14
129
37
8
119
$
$ ./hanoi 2 # move 2 discs, from A to B by C
from A to C
from A to B
from C to B
$ ./hanoi 3 # move 3 discs, from A to B by C
from A to B
from A to C
from B to C
from A to B
from C to A
from C to B
from A to B
$
$ ./showdir /var/tmp/exer9-test-dir
exer9-test-dir/
|---city/
| |---lapula --> ../sky/temple/utopia
| `---rome
|---dogs/
`---sky/
|---birds
|---mountains
`---temple/
|---asking
`---utopia
$ tree -F /var/tmp/exer9-test-dir
/var/tmp/exer9-test-dir
|-- city/
| |-- lapula -> ../sky/temple/utopia
| `-- rome
|-- dogs/
`-- sky/
|-- birds
|-- mountains
`-- temple/
|-- asking
`-- utopia
4 directories, 6 files
$
$ cat IN-7
# sample input file of exercise 7
# this is an blank line.
1234 Alice # Alice wins 1234
999 Bob # Bob wins 999
Alice 200 # Alice spends 200
Bob 100 Alice # Bob loses 100 to Alice
4000 Bob 250 Carol # Bod wins 4000 and loses 250 to Carol
3000 Carol 300 # Carol wins 3000 and spends 300
$ ./ex10.awk IN-7
Carol has 2950
Bob has 4649
Alice has 1134
$
deadline: 2017 Dec 22, 00:05 am
$ 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