测试

2022/1/4 23:15:40

本文主要是介绍测试,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录
  • HW 1
    • 1.Create a new directory called missing under /tmp;
    • 2.Look up the touch program. The man program is your friend.
    • 3.Use touch to create a new file called semester in missing.
    • 4.Write the following into that file, one line at a time:
    • 5.Try to execute the file. Understand why it doesn’t work.
    • 6.Run the command by explicitly starting the sh interpreter.
    • 7.Look up the chmod program
    • 8.Use chmod to make it possible to run the command ./semester.
    • 9.Use | and > to write the “last modified”date output by semester into a file called last-modified.txt in your home directory.

HW 1

1.Create a new directory called missing under /tmp;

mkdir /tmp/missing

检验:

image-20210729190920260


2.Look up the touch program. The man program is your friend.

man touch

结果:

image-20210729191336310


3.Use touch to create a new file called semester in missing.

touch /tmp/missing/semester

4.Write the following into that file, one line at a time:

image-20210729192316666

echo '#!/bin/sh' > /tmp/missing/semester
echo 'curl --head --silent https://github.com/siyuanluo' >> /tmp/missing/semester

单引号字符串非转义

检验:

vim /tmp/missing/semester

image-20210729192457708


5.Try to execute the file. Understand why it doesn’t work.

./semester
ls -l

结果:

image-20210729192854761

users的权限是-rw, 第一组, 没有执行权限x


6.Run the command by explicitly starting the sh interpreter.

sh semester

结果:

image-20210729193345938

解释: OS会通过sh命令的调用直接产生一个新的Shell进程,并将semester当作命令行参数传进去。新的Shell进程就会读取、解释并执行该脚本,而OS不关心该文件到底是什么,自然也就不要求可执行权限,只要求读权限就可以了


7.Look up the chmod program

man chmod

image-20210729193757700

太长头疼, 还是这个吧: Linux chmod 命令 | 菜鸟教程 (runoob.com)


8.Use chmod to make it possible to run the command ./semester.

chmod 744 semester
./semester

image-20210729194506541

给用户开权限x, 顺序是rwx, 全开就是111(2)->7


9.Use | and > to write the “last modified”date output by semester into a file called last-modified.txt in your home directory.

最后一问有点不太会... 哪个是last-modified time... output里面没找到啊



这篇关于测试的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程