linux 编写一个shell脚本文件,实现以下功能

2024-12-20 07:32:06
推荐回答(2个)
回答1:

#!/bin/bash
while true
do
    read -p "请输入学生学号:" stu_num
            if [ $stu_num == exit ];
            then
                    exit
            fi
    read -p "请输入学生姓名:" stu_name
    read -p "请输入学生成绩:" stu_ach
    stu_info=$(echo $stu_num $stu_name $stu_ach)
    Stu_Ach=$(echo $stu_info |awk '{print $3}')
    if [ $stu_ach -gt '60' ];
    then
        echo $stu_num $stu_name $stu_ach >> pass.dat
    else
        echo $stu_num $stu_name $stu_ach >> nopass.dat
    fi
done

欢迎指正




回答2: