Intro. to Unix
Spring 2000

Homework #1

Due Date: Feb 3rd


There are 3 tasks listed below that you need to complete. Each task involves creation of a command line to accomplish some function. You will need to use a variety of Unix commands (and put them together with pipes) to accomplish these tasks.

There are many ways to do any of these tasks!

Task #1

Create a command that lists the files sorted by size (the largest file is on the first line, the smallest on the last line). Here is an example: Suppose the files in the current directory are:
>  ls -l
total 2031
-rw-r--r--  1 hollingd  grads      996 Jan 13  1999 RESULTS
drwxrwx--x  4 hollingd  grads     1024 Jan 18  1999 coordeval/
drwxrwx--x  2 hollingd  grads     1536 Jan 15  1999 new/
-rw-r--r--  1 hollingd  grads  1415376 Jan 18  1999 new.tar.gz
drwxrwx--x  2 hollingd  grads     1536 Jan  7  1999 old/
-rw-rw----  1 hollingd  grads   636968 Dec 10  1998 reactive-sat.ps
drwxrwx--x  2 hollingd  grads      512 Jan 13  1999 test/
The output of your command should look something like this:
 141537699 new.tar.gz
   63696898 reactive-sat.ps
     153699 new/
     153699 old/
     102499 coordeval/
      99699 RESULTS
      51299 test/
Each line should contain only the size and name of the file/directory (no permissions, dates or other fields).
Your answer to this task is a command line that produces the output requested for the current directory (probably starts with "ls -l |" )


Task #2

Check out the wc command (word count). If you give wc the name of a file it will generate output like this:
> wc foo
     247    1159    7210 foo
The output indicates that there are 247 lines in foo, 1159 words and 7210 characters.

I want this output, but I want it to look like this:


247
1159
7210
Specifically, I want each value on a line by itself with no leading whitespace, and I don't want to see the name of the file. HINT: Look at tr including the -s option.

Your answer to this task is a single command line that produces the output requested for a file named "foo" (the numbers will be different).


Task #3

Create a command line that will print out the current month and year on a single line, (nothing else). I want the name of the month to be the complete name (not an abbreviation) and it should be upper case. For example:

   JANUARY 2000
or
   FEBRUARY 2000
HINT: the cal command might be helpful.

Submitting your answers

Send your answers to the email address introunix-submit@cs.rpi.edu with the subject line set to "HW1". This is an automated system that will send you a receipt indicating that it received your email. This is a program sending you a receipt, not a human.

Feel free to include the results of testing that you did (sample output), a description of any problems you had or anything else you think might help us. Please also indicate what flavor of unix you used to develop your answers (Sun, Linux, BSD, SGI, IBM, ...).

If you have questions, check out the HW1 FAQ on the course home page (as we get questions we will create this document) or send email to introunix@cs.rpi.edu.