CS 114: UNIX Tools
Homework 2

Due Friday, March 9, 2:30 PM

Problem 1:
This problem asks you to access information in a number of text files.

Follow the instructions in the file ~cs114/HW2/P1.txt and hand in the answers to the questions that it poses.

Problem 2:
This problem asks you about foreground and background processes.

Consider the following session on babbage:

babbage% jobs
[1] - Suspended find / -name find
[2] + Suspended vi temp.txt
babbage% sort -u verylarge.txt > file &
[3] 16186

This session now has three jobs associated with it.

2.1: What is the status of each of these jobs: stopped, running in the foreground, or running in the background?

2.2: For any non-running processes, how would you make them resume running in the foreground?

2.3: How would you remove process 2 without letting it run any further?

Problem 3:
This problem asks you to demonstrate your familiarity with basic unix commands and with redirection. Do not use ; or awk.

Build one-line commands that:

3.1: Returns ONLY the number of users currently logged in to babbage.

3.2: Add a list of the current processes you are running (in any format) to the end of the file "processlist". (This can include background and stopped processes.)

3.3: Prints to the screen the process ID (and ONLY the process ID) of any csh or tcsh processes that any user is running on babbage. (For extra credit, show only csh processes.)

3.4: Stores a list of the contents (ignoring hidden files) of the directories /usr/bin and /usr/local/bin in the file "progs", sorted alphabetically. (Note: in some approaches, you may find the lines:

/usr/bin:
/usr/local/bin:

at the top of your file - make sure these are removed so that only the files within the directories are listed. You may leave the extra blank line in the file, though.)

Hand in the on-line command that performs each of the above tasks.