CMPSCI 197J: HW2

 NAME: ..........................................                                            DUE DATE: Jan 12, 1999
 

Answer the following questions and write out the exact command(s) you used (100 points)

       A.                                                                                                                        25 points

    1. List all  files in your homedirectory (including dot files).

    2. List only the dot files in your homedirectory and recursively list the directories starting with a dot.

    3. Use the command file with the option -f to display the types of the files in your home directory with a one line command.

    4. What is the  PID of your login shell? Explain in detail your choice of a number from the output of the command ps.

    5. Create a file that contains the process numbers associated with at least two jobs arranged in descending order.
    example contents of output file:
    2930
    2928

    B.                                                                                                                        75 points

    1. Write a script which will write your username, your homedirectory, the type of terminal and the printer that lp uses, so that the output looks like

    Your username is chris
    Home directory is /cs/ugrad/chris
    You are using a terminal which is a vt100
    The default lineprinter is cs/p1.

    2.  Write a script which finds the oldest file in your home directory and prints name and the size of file on the screen preceded by the message

    The name and size of file are:
    xyz      475

    3.  List names of files in your home directory which

    1.  start with a d;
    2. end with an e;
    3. start with y and ends with h
    4. contains exactly 4 letters
    5. contains at  least 4 letters


    4.  Use the commands ps, kill, jobs, fg, bg, grep

    1. Display the list of current processes
    2. Displays only the active processes.
    3. List all the processes(by all users) on the system
    4. Run the command top. How will u exit it?
    5. What does the command kill -9 %1 do?


    5.  Redirections and commands cat, wc, tail, head.
     

    1. How many lines are there in the file /etc/termcap? How many words? How many characters?
    2. Print the 18th line, the last 20 lines
    3. How many words are there in the lines 30-40.
    4. Create a file which contains the first 10 lines of termcap and another file which contains the last 10 lines.
    5. Combine the contents of the two files created above and put it in a new file called extremes.


    Extra Credit:                                                                    (15 points)

    Explain in detail what the following 2 commands do

    echo baz 2>"foo" >&2

    echo baz >&2 2> "foo"
     

    *Some of the questions above have been authored by Regis VIncent