Sponsored Content
Top Forums Shell Programming and Scripting Reading 5 Students names and grades using while loop???? Post 302147201 by dlbomber1 on Monday 26th of November 2007 12:34:51 AM
Old 11-26-2007
Reading 5 Students names and grades using while loop????

How do I write a shell script file to read 5 student names (First and Last name) and their grades using a While Loop? Find the Average, Maximum, and Minimum of grades using the same While Loop. Prompt the user using tput to enter the information (first name, last name, grade). Save the data in a file called students.txt. Sort the file by last name and display it on the screen. Someone gave me this to go buy but im way basic and am not sure if there is anything missing from this. I also need to be able to use Tput.
If anyone can help me get this done or tell me whats missing id appreciate it.

1. suppose file is of form "Name Surname Grade"

#!/bin/zsh

sum=0
min=10000
max=0
n=5
i=0
file="students.txt"

cat $file | while read line; do
set line
grade=$3
sum='expr $sum + $grade'
if [ $grade -gt $max ]; then
max=$grade
fi
if [ $grade -lt $min ]; then
min=$grade
fi
i='expr $i + 1'
if [ $i -ge $n ]; then
break
fi
done

average='expr $sum / $i'
echo "Max: $max Min: $min Avg: $average"
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

executing scripts by reading names from a file

file.txt contains ------------------ sat1 1300 sat2 2400 sat3 sat4 500 I need to write a shell script that will output like the below #output sat1.ksh 1300 sat2.ksh 2400 sat3.ksh sat4.ksh 500 my try ------- #!/bin/ksh for i in `cat file.txt` (3 Replies)
Discussion started by: konark
3 Replies

2. Shell Programming and Scripting

help with a 'while read' loop to change the names of files

Hi, I am new to scripting, so any help on this would be much appreciated. I am trying to rename a bunch of files, taking the names sequentially from a list read in another file... # ls oldnames file_1 file_2 file_3 # cat names red yellow green I want the files to take on the... (6 Replies)
Discussion started by: starsky
6 Replies

3. Shell Programming and Scripting

File Names in a Variable in a loop

Hi All , I am having confusion in a shell script. Please guide me. I need to get multiple files (number of files vary time to time, file names are separated by '|') using FTP get from the remote server. Actually, i call the FTP function in a loop. At the last step, i need to move all the get... (3 Replies)
Discussion started by: spkandy
3 Replies

4. Shell Programming and Scripting

Problem with File Names under tcsh loop

Hello, I have a question regarding file naming under a loop in tcsh. I have the following code: #!/bin/tcsh foreach file (test/ProteinDirectory/*) # The * is a bunch of ProteinFile1, ProteinFile2, ProteinFile3, etc. sh /bioinfo/home/dgendoo/THREADER/pGenThreader.sh $file $file ... (4 Replies)
Discussion started by: InfoSeeker
4 Replies

5. UNIX for Dummies Questions & Answers

Loop through directory names

Some guidance is highly appreciated. I have 10 directories with names ending with 'xyz', each of them have about 30000 files. I want to loop through the contents of each directory and produce a single output per directory. So I want to have 10 output files named 'directory_name'_out. With... (1 Reply)
Discussion started by: newbie83
1 Replies

6. Shell Programming and Scripting

Print file names in a loop

OS : RHEL 6.1 Shell : Bash I have lots of files in /tmp/stage directory as show below. Using a loop, I need to print all the filenames in this directory except those ending with a number. How can I do this ? # pwd /tmp/stage # # # ls -l * -rw-r--r--. 1 root root 0 Oct 7 18:38 stmt1... (2 Replies)
Discussion started by: kraljic
2 Replies

7. Homework & Coursework Questions

Grades exercise

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell script program that will input a name and a mark between 0 and 100. The program then displays the... (9 Replies)
Discussion started by: UniverseCloud
9 Replies
MAC_LOMAC(4)						   BSD Kernel Interfaces Manual 					      MAC_LOMAC(4)

NAME
mac_lomac -- Low-watermark Mandatory Access Control data integrity policy SYNOPSIS
To compile LOMAC into your kernel, place the following lines in your kernel configuration file: options MAC options MAC_LOMAC Alternately, to load the LOMAC module at boot time, place the following line in your kernel configuration file: options MAC and in loader.conf(5): mac_lomac_load="YES" DESCRIPTION
The mac_lomac policy module implements the LOMAC integrity model, which protects the integrity of system objects and subjects by means of an information flow policy coupled with the subject demotion via floating labels. In LOMAC, all system subjects and objects are assigned integrity labels, made up of one or more hierarchal grades, depending on the their types. Together, these label elements permit all labels to be placed in a partial order, with information flow protections and demotion decisions based on a dominance operator describing the order. The hierarchal grade field or fields are expressed as a value between 0 and 65535, with higher values reflecting higher integrity. Three special label component values exist: Label Comparison low dominated by all other labels equal equal to all other labels high dominates all other labels The ``high'' label is assigned to system objects which affect the integrity of the system as a whole. The ``equal'' label may be used to indicate that a particular subject or object is exempt from the LOMAC protections. For example, a label of ``lomac/equal(equal-equal)'' might be used on a subject which is to be used to administratively relabel anything on the system. Almost all system objects are tagged with a single, active label element, reflecting the integrity of the object, or integrity of the data contained in the object. File system objects may contain an additional auxiliary label which determines the inherited integrity level for new files created in a directory or the alternate label assumed by the subject upon execution of an executable. In general, objects labels are represented in the following form: lomac/grade[auxgrade] For example: lomac/10[2] lomac/low Subject labels consist of three label elements: a single (active) label, as well as a range of available labels. This range is represented using two ordered LOMAC label elements, and when set on a process, permits the process to change its active label to any label of greater or equal integrity to the low end of the range, and lesser or equal integrity to the high end of the range. In general, subject labels are rep- resented in the following form: lomac/singlegrade(lograde-higrade) Modification of objects is restricted to access via the following comparison: subject::higrade >= target-object::grade Modification of subjects is the same, as the target subject's single grade is the only element taken into comparison. Demotion of a subject occurs when the following comparison is true: subject::singlegrade > object::grade When demotion occurs, the subject's singlegrade and higrade are reduced to the object's grade, as well as the lograde if necessary. When the demotion occurs, in addition to the permission of the subject being reduced, shared mmap(2) objects which it has opened in its memory space may be revoked according to the following sysctl(3) variables: o security.mac.lomac.revocation_enabled o security.mac.enforce_vm o security.mac.mmap_revocation o security.mac.mmap_revocation_via_cow Upon execution of a file, if the executable has an auxiliary label, and that label is within the current range of lograde-higrade, it will be assumed by the subject immediately. After this, demotion is performed just as with any other read operation, with the executable as the tar- get. Through the use of auxiliary labels, programs may be initially executed at a lower effective integrity level, while retaining the abil- ity to raise it again. These rules prevent subjects of lower integrity from influencing the behavior of higher integrity subjects by preventing the flow of informa- tion, and hence control, from allowing low integrity subjects to modify either a high integrity object or high integrity subjects acting on those objects. LOMAC integrity policies may be appropriate in a number of environments, both from the perspective of preventing corruption of the operating system, and corruption of user data if marked as higher integrity than the attacker. The LOMAC security model is quite similar to that of mac_biba(4) and mac_mls(4) in various ways. More background information on this can be found in their respective man pages. SEE ALSO
mmap(2), sysctl(3), mac(4), mac_biba(4), mac_bsdextended(4), mac_ifoff(4), mac_mls(4), mac_none(4), mac_partition(4), mac_portacl(4), mac_seeotheruids(4), mac_test(4), mac(9) HISTORY
The mac_lomac policy module first appeared in FreeBSD 5.0 and was developed by the TrustedBSD Project. AUTHORS
This software was contributed to the FreeBSD Project by Network Associates Labs, the Security Research Division of Network Associates Inc. under DARPA/SPAWAR contract N66001-01-C-8035 (``CBOSS''), as part of the DARPA CHATS research program. BSD
December 11, 2002 BSD
All times are GMT -4. The time now is 03:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy