-
Lesson 1 - 最简单的C程序
-
Lesson 2 - 打印输出
-
Lesson 3 - 循环打印
-
Lesson 4 - 判断奇偶
-
Lesson 5 - 从1加到100求和
-
Lesson 6 - 乘法表
-
Lesson 7 - 求100以内的最大素数
-
Lesson 8 - 1到100有多少个9
-
Lesson 9 - 整型转字符串
-
Lesson 10 - 约瑟夫环
-
Lesson 11 - 求两个坐标点之间的距离
-
Lesson 12 - 判断机器存储是否小尾端
-
Lesson 13 - 对不起,你的车今天限行
-
Lesson 14 - 判断地图上某点是否有出路
-
Lesson 15 - 统计一个数二进制表示中1的个数
-
Lesson 16 - 字符串拷贝
-
Lesson 17 - 统计单词个数
-
Lesson 18 - 实现 printf
-
Lesson 19 - 命令解释器
-
Lesson 20 - 预处理器实现
-
Lesson 21 - 词法分析器实现
-
Lesson 22 - 猜数游戏
-
Lesson 23 - 五子棋
-
Lesson 24 - 超链接分析器
-
Lesson 25 - cp命令实现
-
Lesson 26 - ELF文件头分析器实现
-
Lesson 27 - 简单流处理器实现和正则表达式
-
Lesson 28 - 数学计算器实现
-
Lesson 29 - 数学计算器实现more命令实现
-
Lesson 30 - sort命令实现
-
Lesson 31 - ls -l命令实现
-
Lesson 32 - Bash项目
-
Lesson 33 - 动态数组实现
-
Lesson 34 - 约瑟夫环问题
-
Lesson 35 - 表达式求值问题
-
Lesson 36 - 广度优先解决迷宫问题
-
Lesson 37 - 词频统计器
-
Lesson 38 - 堆排序问题
-
Lesson 39 - 构造符号表
-
Lesson 40 - MyDictionary项目
-
Lesson 41 - BSearch 实现
-
Lesson 42 - QSort 实现
-
Lesson 43 - 深度优先解决迷宫问题
-
Lesson 44 - KMP 算法实现
-
Lesson 45 - 最长公共子序列(LCS)问题
-
Lesson 46 - Dijkstra 算法
-
Lesson 47 - Huffman Coding 算法
-
Lesson 48 - 地图导航项目
Lesson 32 - Bash Clone (Bash项目)
参考资料
BashClone 项目设计
整个项目新建一个目录 bashclone
每个命令单独建一个目录,目录名就是生成的可执行文件名
- mycp
- readelf
- sed
- math
- more
- sort
- ll
根目录下的主要文件
- main.c shell.c
- Makefile
make all
- 编译整个项目
make test
- 单独测试每个命令
./bashclone 执行程序
limingth@gmail ~/Github/NCCL.codes/Lesson-32$ ./bashclone
demo argc & argv
NCCL# mycp /usr/include/stdio.h stdio.h
NCCL# readelf shell.o
n = 1
HSIZE = 48
type = 1
Type: REL
NCCL# readelf bashclone
n = 1
HSIZE = 48
type = 2
Type: EXEC
NCCL# sed 's/unix/linux'
I love unix, unix is a great os. unix is better than linux.
I love linux', unix is a great os. unix is better than linux.
NCCL# sed 's/unix/linux/g'
I love unix, unix is a great os. unix is better than linux.
I love linux', linux is a great os. linux is better than linux.
NCCL# sed 's/unix/linux/3'
I love unix, unix is a great os. unix is better than linux.
I love unix', unix is a great os. linux is better than linux.
NCCL# math sin 1
result = 0.841471
NCCL# math sqrt 2
result = 1.414214
NCCL# more test.txt
lines = 7
w = 89, h = 27
1 red
5 black
15 blue
30 green
17 yello
2 blue
15 blue
NCCL# sort test.txt
1 red
5 black
15 blue
30 green
17 yello
2 blue
15 blue
--- after sort ---
1 red
15 blue
15 blue
17 yello
2 blue
30 green
5 black
NCCL# sort test.txt -n
1 red
5 black
15 blue
30 green
17 yello
2 blue
15 blue
--- after sort ---
1 red
2 blue
5 black
15 blue
15 blue
17 yello
30 green
NCCL# sort test.txt -u
1 red
5 black
15 blue
30 green
17 yello
2 blue
15 blue
--- after sort ---
1 red
2 blue
5 black
15 blue
17 yello
30 green
NCCL# sort test.txt -r
1 red
5 black
15 blue
30 green
17 yello
2 blue
15 blue
--- after sort ---
5 black
30 green
2 blue
17 yello
15 blue
1 red
NCCL# ll test.txt
Access mode: 0100644
file uid = limingth
file size = 56
file last modify mtime = Sat Jan 25 00:12:24 2014
The time is 01 25 00:12:24 2014
NCCL# ll test.txt -i
file st_ino = 16128001
NCCL# ll test.txt -s
file st_blocks = 8
NCCL# ll test.txt -T
The time is 01 25 00:12:24 2014
copy