How to Calculate My Grade Point Average in UNIX

104 8
    • 1). Log-in to the system. Launch a command shell, either by logging-in in text mode, or by launching a Terminal window from the graphical user interface.

    • 2). Make sure that your numeric grades are stored in a file, one per line, with no additional content. Do not include any extraneous lines in the file with alphabetic characters, or empty lines containing only carriage returns. You can generate such a file by hand with any text editor, or by importing it from another application; it depends on the source of the information.

    • 3). Type the following command into the shell:

      awk 'BEGIN{s=0;}{s=s+$1;}END{print s/NR;}' gradesFile

      Replace "gradesFile" with the name of the file containing your grades.

    • 4). Press "Enter." Awk will output your GPA after having scanned all the input file.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.