horizontal rule

 

CS 140U
50 POINTS

DUE announced in class

NAME:

INSTRUCTIONS:

a) Login to your UNIX account and make sure C-Shell is your current shell.

b) Do the steps is each question and write the required answer in the space provided.

c) For questions 12-16 assume a file named students containing the following data exists in your current directory. Each line in this file represents a student's first name, last name, and 3 exam scores. Each line should be regarded as a record containing 5 fields separated by one or more tab characters. You must use the awk command to answer these questions (Note: This file exists in /u/staff/si/CS140U/PUBLIC/hw5.dat).

Tom     Jones     100    90     80
Nancy   Jones    70     80      90
Terry   Sims     55     65      75
John    Terry    75     76      77
Ruth    Maier    100    100     100
Mike    Wolfe    90     95      98
Dennis  Cole     70     80      89
Ron     Maier    90     85      89
Susan   Miller   65     80      90
Mad     Bill     75     65      77

1) What is the output for each of the following echo commands?

% set n = "Ken Thompson"

a)  % echo n
b) % echo $n
c) % echo "$n"
d) % echo 'n'
e) % echo \$n

 

2) Using the variable n in the previous question and the echo command, write a command line that displays the following message:

"The value in variable n is $n and is equal to ken Thompson"

Note: This should work for any variable named n (with any contents). The double quotes must be displayed as well.

3) There are two special characters that can't be turned off with either single or double quotations (in C-shell). What are these characters?

4) Explain the difference between the .cshrc and the .login files in a user's home directory (Note: in terms of how when they are processed by the C-shell).

5) How are the following commands different?

a) % set d = date

b) % set d = `date`

6) First view the contents of the /etc/passwd file a few times to get familiar with its contents. Then, using the grep command, display the entry for your account in the /etc/passwd file (can assume that your user information has been updated with the chfn command). Note: for this question just write the command line for the grep command.

7) Using the grep command display a list of currently logged in users whose account name begins with the same letter as your account (use the output of who and pipe). Note: Just write the command line that accomplishes this.

8) Using the grep command display a long list of all directories (only) in your ~. Note: just write the command line.

9) Use the grep command to display your ~/.cshrc file with line numbers. Note: just write the command line.

10) How are the following file (or directory) references different in C-shell?

a) ~xyz
b) ~/xyz

11) Using the grep command create an alias that displays the number of login sessions a particular user (any user) is currently using.

12) What command line would display the contents of the students file with line numbers in front of each line?

13) What command line would display the contents of students file such that first names and last names are swapped?

14) What command line would display the contents of the students file with the following logo?

FIRST_NAME     LAST_NAME      EXAM1     EXAM2     EXAM3

15) What command line would only display the number of lines in the students file?

16) What command line would display the first and last names of those who got 100 on their first exam (there are examples in the book)?

 

 

horizontal rule

Back to CS140U Homepage
This page was last modified January 07, 2008
wmorales@pcc.edu