Shell 读取文件的脚本帮助

Shell script help for reading in file

我有一个作业,我正在阅读一个文件,这是我的代码

#Reads in file
while read line; do
echo `wc -l` "is the number of students in the input file."
echo `grep '^[^4]'| wc -l`

done <students.txt

本质上,我试图显示不以 4 开头的学生 ID 的数量。我希望 grep '^[^4]'| wc -l 可以解决问题,但它只是 returns 0。下面是正在读入的文本。关于如何完成此操作的任何建议(这是 UNIX 的介绍 class,所以我不能现在真的在上面使用任何东西哈哈)。

256-56-8411  Bob      3.61  junior     cs
471-44-7458  Tim      3.45  senior     ce
326-56-4286  Rajesh   2.97  freshman   te
548-66-1124  Eric     2.88  sophomore  ee
447-21-3599  John     2.51  junior     cs
911-41-1256  Rebecca  3.92  senior     cs
854-22-6372  Robin    2.45  freshman   te

是否必须使用 read?因为你不必。您如何看待简单的 grepwc -l

FILE="students.txt"

echo "$(cat "$FILE" | wc -l) is the number of students in the input file"
echo "$(grep -c '^[^4]' "$FILE") is the number of student ID's that do not start with a 4"