Linux实验 shell程序开发,只是参考 不是标准
任务二代码部分注意格式空格
#!/bin/bash
echo -n "input student ID:"
read ID
i=0
k=0
cat /root/workspace/shell/data.txt | awk 'NR<3' | while read line
do
echo $line
done
cat /root/workspace/shell/data.txt | awk 'NR<2' | while read no1 line
do
if [ $no1 -eq $ID ]
then
k=$i
else
i=$(($i+1))
fi
if [ $k -eq $i ]
then
cat /root/workspace/shell/data.txt | awk 'NR=$(($k+2))'
echo $no1 $line
fi
done