BCS 215 Final Exam
In your home (login) directory,
create a subdirectory named "shared".
Set permissions allowing new files to be created by
anyone in the group "/home/students/"
BUT not allowing directory to be searched.
Users outside the group can access
a file if (and only if) they know the file name.
Create the following files in this (~/shared/) directory:
-
A hidden file with a name that ends with the last two digits of your RAM ID number.
- Write the full path name of the hidden file in a new (non-hidden) file whose name is your first name, beginning with a Capital letter.
- Create a file named "run" that anyone can execute,
but only group members can read, and nobody but you can write.
- Create a file named "frozen" that anyone can execute,
but nobody can read or write.
- Create a file named "public" that anybody can read/write, but only you can execute.
- Create a file named "secret" that anyone can execute, but only you can read or write.
- Create a file named "top" that only you can read (and nobody can write or execute).
Everything below
should be in your
~/final/
directory
("~/final/"),
along with your projects
three,
four,
five.
Execute unix commands
to write the following to a file named six,
in your ~/final/ dir.
- Your First and Last name.
- Today's date and time.
- What day of the year (from 1 to 365) is today?
- How many user names (in "/home/students/")
begin with same first letter as yours?
Make a link to the
"presidents/"
file in my "final/" directory
(or to link in my "bam/" directory),
and use it for the next 5 items.
|
- In the
"presidents/"
file,
how many lines
do NOT contain the string "None"?
- How many lines do NOT contain either "John" OR "William"
- The 5th field contains a range of years separated with a dash, such as "(1861-1865), OR a single year, such as "(1841)".
How many lines have NO dash in this field.
- The 9th field also contains either a range of years or a single year. Count how many lines do NOT have a dash in this field.
Store your command history in a file named "h".
In your ~/final/ directory,
write a bash script named
seven
that asks the user to enter a list of positive numbers,
one per line,
with a zero at the end of the list.
As each positive value is read in, do the following:
- * Output the value, add it to total "t", and add one to counter "n".
- $ Update variables "hi" & "lo"
to contain biggest & smallest values read in, so far.
(HINT: Initialize both of these to the first value read in, before starting input loop.)
- $ Square each input number (i.e. multiply it by itself), and add that to a quantity called "ss" (for the sum of the squares).
SUGGESTION:
Do starred (*) items first;
add "$" items later.
|
When the zero is read in, do the following:
- * Be sure NOT to increase the counter!
- * Divide total (t) by counter (n), to compute average.
(HINT: Don't worry about losing any fractions when these two integers are divided.)
- $ Set "tt" equal to the square of the total "t"
(by multiplying t by itself).
- $ Set "diff" equal to ss - tt/n
- $ Compute the variance v = (ss - tt/n) / n
( = diff / n )
- * Output the following (with approriate text to identfy each result):
- * The total (t).
- * The number of input values (n).
- * The mean average of the values.
- * The range of values (smallest to biggest).
- $ Sum of the squares (ss), tt/n, and diff.
- $ Variance (v)
Test your script, with output to console,
and input from keyboard;
then run it with
input from data files in ~martinb/final/
and output to files in your
~/final/
dir.
Enter a list of positive values
(ending the list with zero).
11
12
13
14
15
16
17
18
19
0
Smallest: 11
Biggest: 19
Total is 135
Count is 9
Average: 15
-------
ss-tt/n= 2085 - 18225 / 9 = 60
variance: 6
|
Below are some tests you can perform:
- If all values are equal, variance should be zero.
- If values in list are very different, variance is large.
- If hi & lo are far apart, variance should be large.
- If the list contains the numbers 1 thru 10,
average should be 5 and variance should be 8.
- If the list contains "100 200 300"
the average should be 200 and the variance should be 666.
Input from ~martinb/final/data.1;
and redirect output to your file
seven.1.
Input from
~martinb/final/data.2.
and redirect output to
seven.2.
Input from ~martinb/final/data.3.
and redirect output to
seven.3.
Input from ~martinb/final/data.4.
and redirect output to
seven.4.