- 課本: Introduction to Linux
- complexity v.s. simplicity (figure from "Starting Forth")
- 我以前作的 上課講義
- 課本 第二章 概述
- 課本 第三章指令簡表
- summary of shell programming
- demo sh script
- demo awk scripts
- note of tar and gzip
- 作業一: find and modify
從 /var/tmp/milk /var/tmp/zoo /var/tmp/sea 三個目錄底下找出自己的檔案,
並使用編輯器(for example, joe or vi) 修改, 使其內容為其檔名.
deadline: 2010 Sep 24, 00:05 am
- 作業二: cloning a directory
在你的 home 目錄底下的 unix-991/exer2 建出一個目錄結構, 使其與
/var/tmp/unix-991-ex2 一樣.
也就是說除了最上層的目錄不同外, ~/unix-991/exer2 與
/var/tmp/unix-991-ex2 要一模一樣. (當然 owner 不可能一樣)
可能用到的命令: mkdir, ln -s, touch, ls, cd, .......
deadline: 2010 Oct 1, 00:05 am
- 作業三: invoking ps with cerain options
查閱 ps 的 man page, 找出適當的參數, 使其執行時只顯示
USER,PID,PPID,COMMAND
將你的東西寫成一個 file 放在 unix-991/exer3 下, 並用 chmod 將其設成
可執行.
deadline: 2010 Oct 22, 00:05 am
- 作業四: a simple sed exercise
呼叫 sed 並提供適當參數, 使其將 S 轉成 $, 將 $ 轉成 $$.
example:
$ cat INPUT
She has $100. I have $100.
She gives me $50. I give her $20.
Now she has $70.
$ ./mysed < INPUT
$he has $$100. I have $$100.
$he gives me $$50. I give her $$20.
Now she has $$70.
$
將你的東西寫成一個 file 放在 unix-991/exer4 下, 並用 chmod 將其設成
可執行.
deadline: 2010 Nov 5, 00:05am
- 作業五: calculate the sums for each user (awk)
寫一 awk script, 把每一個 user 對應的數字加總, 最後印出來.
資料檔的每一行的第一個字元若為 #, 則空一格後接著就是 user name. 底下的
數字就是該 user 的數字.
注意:
- 同一個 user 可能出現很多次.
- user 印出時請依出現次序.
程式請置於 ~/unix-991/exer5/ 下
Deadline: 19 Nov 2010, 00:05am
For example:
my_prompt> cat Input
# klim
23 33 22 11
8888
# oak
1000 200 2200
-22
-3000 -20
# redcow
20000 20000
444
# klim
-1001
2000
# oak
-1000000
20002
my_prompt> ./my-ex5.awk Input
klim 9976
oak -979640
redcow 40444
my_prompt>
- 作業六: calculate the sums for each user (sh)
與前一個作業五相同, 但改用 sh 來做. 但user 印出時不須依出現次序.
程式請置於 ~/unix-991/exer6/ 下
Deadline: 3 Dec 2010, 00:05am
- 作業七: write a Makefile
將 source 解開放至 ~/unix-991/exer7 下,
並補上一個 Makefile, 使其結果如:
$ ls
Makefile copyfile1.c r_read.c readline.c restart.h
copyfile.c copyfilemain.c r_write.c readlinetest.c simplecopy.c
$
$ make
gcc -c -o readlinetest.o readlinetest.c
gcc -c -o readline.o readline.c
gcc -o readlinetest readlinetest.o readline.o
gcc -c -o simplecopy.o simplecopy.c
gcc -c -o copyfile1.o copyfile1.c
gcc -o simplecopy1 simplecopy.o copyfile1.o
gcc -c -o r_read.o r_read.c
gcc -c -o r_write.o r_write.c
gcc -c -o copyfile.o copyfile.c
gcc -o simplecopy simplecopy.o r_read.o r_write.o copyfile.o
gcc -c -o copyfilemain.o copyfilemain.c
gcc -o copyfilemain copyfilemain.o r_read.o r_write.o copyfile.o
$
$ touch restart.h
$ make
gcc -c -o copyfile.o copyfile.c
gcc -o simplecopy simplecopy.o r_read.o r_write.o copyfile.o
gcc -c -o copyfilemain.o copyfilemain.c
gcc -o copyfilemain copyfilemain.o r_read.o r_write.o copyfile.o
$
$ make clean
rm -f *.o readlinetest simplecopy1 simplecopy copyfilemain
$ ls
Makefile copyfile1.c r_read.c readline.c restart.h
copyfile.c copyfilemain.c r_write.c readlinetest.c simplecopy.c
$
Deadline: 22, Dec, 2010, 00:05am
- 作業八: listing number (python)
寫一個 python 程式, 由 argument 讀進一個數字, 若無數字則無輸出,
若數字為偶, 則除以 2, 若為奇, 則乘以3加1, 直到變成1 為止. 如下所示.
$ ./my-ex8.py 32768| fmt
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2
$ ./my-ex8.py 32765| fmt
32765 98296 49148 24574 12287 36862 18431 55294 27647 82942 41471 124414
62207 186622 93311 279934 139967 419902 209951 629854 314927 944782
472391 1417174 708587 2125762 1062881 3188644 1594322 797161 2391484
1195742 597871 1793614 896807 2690422 1345211 4035634 2017817 6053452
3026726 1513363 4540090 2270045 6810136 3405068 1702534 851267 2553802
1276901 3830704 1915352 957676 478838 239419 718258 359129 1077388
538694 269347 808042 404021 1212064 606032 303016 151508 75754 37877
113632 56816 28408 14204 7102 3551 10654 5327 15982 7991 23974 11987
35962 17981 53944 26972 13486 6743 20230 10115 30346 15173 45520 22760
11380 5690 2845 8536 4268 2134 1067 3202 1601 4804 2402 1201 3604 1802
901 2704 1352 676 338 169 508 254 127 382 191 574 287 862 431 1294 647
1942 971 2914 1457 4372 2186 1093 3280 1640 820 410 205 616 308 154 77
232 116 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2
$ ./my-ex8.py | fmt
$
Deadline: 29, Dec, 2010, 00:05am
可能用到的 module 及 function: sys, sys.argv, int(), len()
- 作業九: calculate the sums for each user (python)
用 python 將作業五重新做過.
Deadline: 5, Jan, 2011, 00:05am
- 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)
- python
- vi 的參考資料