Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:15:11+00:00 2026-05-23T04:15:11+00:00

Basically what I have to do is this: I have a file containing names

  • 0

Basically what I have to do is this:

I have a file containing names of students and their partial grades:

(firstname lastname grade)

And what I have to do is update that file with their exam grades and their final grades:

(partial+exam)/2

The exam grades are introduced via the keyboard. So I have to echo a student’s name and read his exam grade from the keyboard, and update his line within the file, then move on to the next one, and when I’m all done sort it after the final grade column.

I’m stuck at reading the exam grade from the keyboard. I’ve tried using some form of awk and sed but cant get it to work (cant get the info from the keyboard) and I’m not even sure if thats how it has to be done.

Please help.

ty in advance,
bando

edit:
(ty for editing, im a bit new to this)

input looks like this:

Tom Green 7
Jenny Patricks 6
Andrew Gibbs 3
Collin Matthews 10

it has to run from a script. while running it should put to standard output the first and last name of a student and ask for his grade. once given it edits the file to look like:

Tom Green 7 9 8

and then steps to the next student.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:15:11+00:00Added an answer on May 23, 2026 at 4:15 am

    This script does something similar you want:

    #!/bin/bash
    
    # $1 input file
    # $2 output file (or equal to $1 if ommitted)
    
    if [ -z "$2" ]; then
        OUTFILE=$1
    else
        OUTFILE=$2
    fi
    
    cat $1 | while read -u 0 FIRST LAST PART ; do
        echo "firstname: '$FIRST'"
        echo "lastname: '$LAST'"
        echo "grade: '$PART'"
        read -p "Exam grade: " -u 1 EXAM
    
        #Edit
        # was   let FINAL=(PART+EXAM)/2
        # should be:
        FINAL=$(calc \($PART+$EXAM\)/2)
    
        echo "$FIRST $LAST $PART $EXAM $FINAL" >> tmp
        echo "final grade: '$FINAL'"
        echo -e "-----------\n"
    done
    
    mv tmp $OUTFILE
    

    But the shell arithmetic is integer only. For dividing you have two operators: / (integer division) and % (reminder). I think you should consider other language for the task like python or perl.


    Edit:
    You may want to use the calc command from the apcalc. See the corrected script above. You’ll have to tweak the calc command options to prevent it from taking over STDIN. Sorry I have to leave you with that – I have no time right now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a revision.txt file in my SVN project. Basically I want that this
Well basically I have this script that takes a long time to execute and
I have a ListView containing file names. These file names need to be draggable
So I basically have this: $img = imagecreatefrompng('assets/other/redcircle.png'); imagepng($img); imagedestroy($img); So the redcircle.png file
I have two sources: an xml-file containing definitions of several hundred data structures, basically
I have this piece of code that basically checks if one or more files
Basically you have two ways for doing this: for (int x = 0; x
I'm not really sure how to title this question but basically I have an
I have an ASP.NET application. Basically the delivery process is this one : Nant
I have written a secure TCP server in .NET. This was basically as simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.