传送门:https://www.shiyanlou.com/courses/running#

步骤一

新建一个 test.sh 输出 Hello Shiyanlou!

步骤二

复制 test.sh 为 test2.sh

修改 test2.sh 实现将 Hello Shiyanlou 保存为 my.txt 文本

步骤三

新建一个 cleantest.sh 脚本运行实现清空 test.sh 里的内容

提示

  • 复制为cp
  • 创建的脚本文件都必须在/home/shiyanlou/

 

实验过程:

步骤一:

vi test.sh

 

sh test.sh

 

步骤二:

cp test.sh test2.sh

vi test2.sh

 

sh test.sh

sh test2.sh

cat my.txt

 

步骤三:

vi cleantest.sh

 

sh cleantest.sh
cat test.sh

 

 

提交结果~当当当当~

 

 

知识点:

为什么 cat /dev/null > test.sh 可以清空test.sh?

因为 /dev/null 这个字符设备文件是空的,他重定向到任何文件都会清空