思考题

Thinking 0.1

执行git status > Untracked.txt,是查询当前README.txt的文件状态,并将其记录在Untracked.txt文件中。后续两个命令同理。

执行完cat Untracked.txt后,显示出未跟踪的文件,说明文件刚刚新建的时候,其处于未跟踪的状态;执行cat Stage.txt后,显示出要提交的变更,说明修改了文件,并使用add命令之后,文件处于暂存的状态;执行cat Modified.txt之后,显示出尚未暂存以备提交的变更,说明文件再被修改之后,处于被修改状态。

Thinking 0.2

add the file 对应的是git中的git add命令

stage the file 对应的也是git中的git add命令

commit 对应的是git中的git commit命令

Thinking 0.3

  1. git checkout --print.c
  2. git reset HEAD print.c && git checkout --print.c
  3. git rm --cached hello.txt

Thinking 0.4

第一次git log如图所示

图片1

第二次git log如图所示

图片2

第三次git log如图所示

图片3

第四次git log如图所示

图片4

Thinking 0.5

执行echo first后如图

图片5

执行echo second > output.txt后如图

图片6

执行echo third > output.txt后如图

图片7

执行echo forth >> output.txt后如图

图片8

Thinking 0.6

command

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash                                                              touch test
echo 'echo Shell Start...' > test
echo 'echo set a = 1' >> test
echo 'a=1' >> test
echo 'echo set b = 2' >> test
echo 'b=2' >> test
echo 'echo set c = a+b' >> test
echo 'c=$[$a+$b]' >> test
echo 'echo c = $c' >> test
echo 'echo save c to ./file1' >> test
echo 'echo $c>file1' >> test
echo 'echo save b to ./file2' >> test
echo 'echo $b>file2' >> test
echo 'echo save a to ./file3' >> test
echo 'echo $a>file3' >> test
echo 'echo save file1 file2 file3 to file4' >> test
echo 'cat file1>file4' >> test
echo 'cat file2>>file4' >> test
echo 'cat file3>>file4' >> test
echo 'echo save file4 to ./result' >> test
echo 'cat file4>>result' >> test

result

1
2
3
3
2
1
  • echo echo Shell Start直接把echo Shell Start作为字符串输出;
  • echo (反顿号)echo Shell Start(反顿号)是将echo Shell Start输出作为外层echo的输入,所以会输出Shell Start
  • echo echo $c>file1直接把echo $c>file作为字符串输出;
  • echo (反顿号)echo $c>file1(反顿号)是将echo $c>file1输出作为外层echo的输入,所以会直接输出$c>file1

实验难点

实验难点

这里借用一下Hyggge学长的图,我个人认为写的非常好,我在进行线上实验的时候也注意到了这些难点,也是我经常在实验过程中回头去看指导书的地方。

在我自己的感觉里,我对awk命令和grep命令比较迷惑,也是看了很多攻略。其中grep命令的正则表达式和java的正则表达式不太一样,还得注意。

实验体会

对于计算机小白的我来说,刚开始接触命令行还是在大二上研究计组的时候。当初跟着同学里的大佬,在研究自动化测试的时候,慢慢开始接触命令行,学会用命令行解析、比对。当初确实感觉,相对图形化界面,命令行的一个极大的优点就是简洁。

当然,CLI对于计算机小白的我还是很有挑战性的。在刚开始使用CLI的时候,面对多种多样的指令、参数,我总是记不住它们的功能,写着写着还要重新去翻指导书,后来慢慢的才习惯了。

道阻且长,行则将至!诸君一起努力!

原创说明

本实验报告参考了Hyggge学长的博客,原文章链接如下:
https://hyggge.github.io/2022/03/21/os/os-lab0-shi-yan-bao-gao/

另外致谢我的舍友黎嘉旋同学,在学习过程中给了我很多帮助和解惑。