- 課本: Introduction to Linux
- complexity v.s. simplicity (figure from "Starting Forth")
- 我以前作的 上課講義
- 課本 第二章 概述
- 課本 第三章指令簡表
- summary of shell programming
- demo sh script
- demo awk scripts
- GNU document for
make
make.
- GNU document for
bash
- GNU document for
sed
- GNU document for
awk
- GNU document for
GNU core utils
coreutils.pdf
(created by dvipdf from coreutils.dvi)
- note of tar and gzip
- python
- vi 的參考資料
- note of tar and gzip
- unix commands vs python
- 作業一: finding files
從 /var/tmp/exercise-one 目錄底下找出自己的檔案,
並在 ~/unix-1011/exer1 下建立一檔案, 名為 "myfiles", 內容為找到的檔名.
一行一個, 共有四個.
如為 /var/tmp/exercise-one/Sam/likes/a-duck
則只需輸入 Sam/likes/a-duck 即可. 注意大小寫.
編輯器可用 joe or vi
deadline: 2012 Sep 26, 00:05 am
- 作業二: cloning files and directories
從 /var/tmp/exercise-two 目錄底下找出自己的目錄及檔案,
並複製到 ~/unix-1011/exer2 下. 如果有以下目錄及檔案
/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-1011/exer2
|---Bob
| `---has-bought
| |---a-cow
| |---a-deer
| `---a-dog
`---David
`---is
`---a-tiger
|---fun
|---is
`---it
deadline: 2012 Oct 3, 00:05 am
- 作業三: invoking ps with cerain options
查閱 ps 的 man page, 找出適當的參數, 使其執行時只顯示
RUSER,USER,PID,PPID,COMMAND
將你的東西寫成一個 file 放在 unix-1011/exer3 下, 並用 chmod 將其設成
可執行.
deadline: 2012 Nov 07, 00:05 am
- 作業四: setting the crontab
- 設定個人的 crontab 使其每一個小時執行以下的程式一次.
為避免大家的程式都擠在整點執行, 若學號後二位為 13 者, 在
每一小時的第 13 分執行, 其它類推.
- 此程式固定作 :
1. 印出一行 separator.
2. 顯示目前時間
3. 印出 /var/tmp/fortune 的最後一行.
- 程式的輸出請 append 到一個檔.
- 程式及輸出檔都放在 ~/unix-1011/exer4 下.
- deadline: 2012 Nov 14, 00:05 am
- 作業五: calculating the sums (awk)
寫一個 awk 的程式, 讀進一個檔, 算出每個人最後有多少錢.
檔的格式及例子如下:
$
$ cat IN-5
# this is a comment line.
Mary has $1000.
John has $200.
Alice has $30000.
# lose
Mary loses $40 to Alice.
Alice loses John $3000.
# win
John wins $5000 from Alice.
Alice wins John $4000.
$
$ ./ex5.awk IN-5
John has $4200.
Mary has $960.
Alice has $26040.
$
deadline: 2012 Dec 5, 00:05 am
作業請放至 ~/unix-1011/exer5 下.
- 作業六: calculating the sums (awk)
與前一作業一樣, 只是 input 較複雜, 如下所示:
-=-prompt-=-> cat IN-6
# this is a comment line.
Mary has $1000.
John has $2000.
Alice has $30000.
Joe has $10000.
Ross has $20000.
Jack has $400.
#
# lose
#
Mary loses $40 to Alice.
Alice loses John $3000.
#
Joe loses $10 and $19 to Alice and John respectively.
Ross loses Joe and Alice $21 and $39 respectively.
#
Mary loses $10, $20, and $30 to Alice, John, and Joe respectively.
Ross loses Joe, John, and Mary $20, $30, and $40 respectively.
#
Each of Alice and Joe loses John $200.
Jack loses $20 to each of Joe and Mary.
#
Each of John, Mary, and Joe loses Ross $10.
Mary loses $10 to each of Alice, John, and Joe.
#
# win
#
Mary wins $40 from Alice.
Alice wins John $3000.
#
Joe wins $10 and $19 from Alice and John respectively.
Ross wins Joe and Alice $21 and $39 respectively.
#
Mary wins $10, $20, and $30 from Alice, John, and Joe respectively.
Ross wins Joe, John, and Mary $20, $30, and $40 respectively.
#
Each of Alice and Joe wins John $200.
Jack wins $20 from each of Joe and Mary.
#
Each of John, Mary, and Joe wins Ross $10.
Mary wins $10 from each of Alice, John, and Joe.
-=-prompt-=->
deadline: 2012 Dec 12, 00:05 am
作業請放至 ~/unix-1011/exer6 下.
- 作業七: generating sentences (sh)
寫一 sh script, 產生以下結果. 若不會 random 產生數字, 可用固定數字,
但不要一樣即可.
-prompt--> ./ex7.sh wins from Alice Bob
Alice wins $143 from Bob.
-prompt--> ./ex7.sh wins nop Alice Bob
Alice wins Bob $170.
-prompt--> ./ex7.sh loses to Alice Bob
Alice loses $189 to Bob.
-prompt--> ./ex7.sh loses nop Alice Bob
Alice loses Bob $21.
-prompt--> ./ex7.sh wins from Alice Bob Cat
Alice wins $266 and $261 from Bob and Cat respectively.
-prompt--> ./ex7.sh wins nop Alice Bob Cat
Alice wins Bob and Cat $38 and $131 respectively.
-prompt--> ./ex7.sh loses to Alice Bob Cat Dog
Alice loses $28, $143, and $46 to Bob, Cat, and Dog respectively.
-prompt--> ./ex7.sh loses nop Alice Bob Cat Dog
Alice loses Bob, Cat, and Dog $137, $85, and $40 respectively.
-prompt--> ./ex7.sh wins from Alice Bob Cat Dog Elephant
Alice wins $43, $194, $212, and $227 from Bob, Cat, Dog, and Elephant respectively.
-prompt--> ./ex7.sh loses to Alice Bob Cat Dog Elephant
Alice loses $96, $230, $152, and $64 to Bob, Cat, Dog, and Elephant respectively.
-prompt-->
deadline: 2012 Dec 19, 00:05 am
作業請放至 ~/unix-1011/exer7 下.
- 作業八: calculating the sum for someone (sh)
寫一 sh script, 計算某人(第一個參數) 的總和. 第二個參數後為多個檔名,
若無指定檔名則從 stdin 讀入. input 的格式見下列例子.
-=-prompt-=-> cat Week-1
klim 120 100 900
milk 98 33 100 120
moo 10000 200 20
cow 2000 10 100000
-=-prompt-=-> cat Week-2
moo 20 100 20 1
cow 299 44 22
cow 333 22 90
klim 49 22
moo 333
-=-prompt-=-> ./ex8.sh moo Week-1
moo has total 10220 dollars.
-=-prompt-=-> ./ex8.sh moo Week-1 Week-2
moo has total 10694 dollars.
-=-prompt-=-> ./ex8.sh moo
moo 1000
cow 200
moo 20 40 30
moo has total 1090 dollars.
-=-prompt-=->
deadline: 2012 Dec 26, 00:05 am
作業請放至 ~/unix-1011/exer8 下.