Beginning exercises in UNIX.

Assignment #2

Note: Remember to follow Assignment Instructions

Set A.

1.

  1. Create two directories, one called yourfirstname (by this I don't mean to name it with the string "yourfirstname" but rather to use your real first name, like "archie", or "betty"), the other called yourlastname;
  2. create files named q1, q2, q3, q4, q5 and q6 inside yourfirstname. 
  3. Do at least three different varieties (based on differing flags) of an ls command on that directory.

2. Use nano or another editor to create a file named w1 (within the directory yourfirstname) containing a  paragraph or two (6 to 8 lines) of text. This should consist of real English sentences which have at least some degree of literary cohesion. As examples, it could be the beginning to a short story you would like to write some day, the story of your life, a letter to a friend, an essay on copyright law, advice to dog owners, a humorous account of a botched romance or anything generally resembling prose. I'll not be grading for grammar, spelling, authenticity, or literary merit, however standard rules of academic citation are always operative. Hence, either create the text yourself, or be sure to use proper academic citation. Output the file to the screen using cat. (Don't worry about trying to capture various phases of the edit session.)

3. Use echo to put a line of text into q2.

4. Copy the contents of w1 into q1.

5.  Using a single command issued from within yourfirstname, move q1 and q2 into yourlastname. While still in the directory yourfirstname, verify that the files q1 and q2 are now in yourlastname, and are no longer in yourfirstname. 

6. Still in yourfirstname, concatenate q1 and q2 into a new file called fcat and stored in yourlastname.

7. Remaining still within yourfirstname, examine and remove all contents of yourlastname.

Set B. (using /usr/share/dict/words, an alias for /usr/share/dict/linux.words)

1. Start a new directory called sleepy. Use pico or another editor to create a file  (inside sleepy) named grumpy containing a new paragraph or two (with exactly 7 lines) of text, using rules similar to those of exercise A2 (but having different prose in it). Output the file to the screen using cat.

2. Use a command to count the words, lines and characters in the file grumpy created in #1. grumpy should have exactly 7 lines.

3. Using a single command, create three files in sleepy, named w1, w2, and w3 . Put the first 7 lines of /usr/share/dict/words
into w1 and the last 7 lines of    /usr/share/dict/linux.words w2. There are 479829  lines in /usr/share/dict/linux.words. Put the contents of lines 10001 through 10007 into w3.

4. Use the touch command to create three new files (named f1, f2 and f3) in sleepy. Use ls to examine the filenames in sleepy.

5. Copy the contents of grumpy into f1.

6. Concatenate w1, w2 and w3 into f2. Using wc, examine the filesizes (including bytes, words and lines) of all three (but none of the other files in sleepy) using a single command.

7. Merge the contents of w1, w2 and w3  side-by-side* into f3. Now examine the file sizes of f1, f2 and f3 (including bytes, words and lines). Make intelligent observations.

* By side by side I mean something like this:

a
b
-
c
d
-
e
f
→
→
→
a c e
b d f

8. From within sleepy, use a single command to move w1,  w2 and w3   [but not the other files] from the sleepy directory into your top level directory. From within sleepy, list the contents of your top level directory.

9. Modify the permissions of all files in sleepy so that they have "world" read and execute privileges.