检查有谁没有上传作业
- 现有作业上传目录/opt/upload及学员名单/opt/name.txt(自己随便编一下,tom jerry zhangsan ...),要求每人要以自己的名字上传作业.
写一个脚本,能够检查有谁没有上传作业. 其中tom同学因休学,不需要提示. //用while或者for都可以
例
bash homework.sh
未交作业的同学有:
jerry zhangsan
!/bin/bash
#!/bin/bash
for i in `cat name.txt`
do
if [ $i == "tom" ]
then
continue
else
ls upload|grep -qw $i
if [ $? -ne 0 ]
then
echo -n "$i "
fi
fi
done>a.txt
grep -q "." a.txt
if [ $? -ne 0 ]
then
echo "所有同学都交了"
else
cat a.txt
echo
fi