Colorado State University

This file defines the header for each page. An optional "icon" image (I use the textbook):

Three headers follow: ! Long name of class !! Semester !!! HW 3, replaced by the name of the current page.

CS155: Introduction to Unix

Fall 2013

HW 3

Links to the various pages for this class:

Wish I could do this: * Schedule

CS155 HW3: Manipulating files, directories, and archives

Summary

For this assignment, you will:

Details

Do not use an editor unless it specifically states to edit the file. By “editor” I mean vim, gedit, pico, etc. Despite its name, we don’t consider sed to be an editor in this assignment.

  1. You will find a file named hw3.tgz in ~cs155/pub; untar it in your home directory.
    It will create a directory called hw3_files
  2. Go into the hw3_files directory.
  3. Create a backup of the file story.txt, call it story.old-version
  4. Change the permissions of story.old-version so that everyone can read it, but nobody can write or execute it.
  5. Create a copy of story.txt but change all of the occurrences of “Alice” to “Ninja” and store this in a new file called story.ninja
    (do not use an editor—this is a one-line command).
  6. Find the one line in story.ninja which contains the string “some” but does not contain the letter “n” (upper/lower case matters) and put it in the file some-n.txt
    (do not use an editor—this is a one-line command).
  7. Count the number of words in story.txt and append a line containing just that number to the end of some-n.txt.
  8. Change the permissions of the file runme so that you can read, write and execute it, members of your group can read and execute it, and everyone else can only read it.
  9. Execute runme and put the output it produces into a file named runme.out
  10. Edit the file runme and change the number 855 to 355.
  11. Make sure that the permissions of runme did not change when you edited the file. If they did, fix them.
  12. Execute runme again and put the output it produces into a file named runme.outout
    (do not use an editor).
  13. Find the differences between file_1.txt and file_2.txt and put them into a new file named file_3.txt
    (do not use an editor).
  14. Create a file named current.txt which contains the current time and date of the machine you are using, as reported by the date command
    (do not use an editor).
  15. Execute the file runme2 and append its output to the file current.txt
    (do not use an editor).
  16. Copy lines 14–21 of the file data.txt into a file named octopus
    (do not use an editor).
  17. Go into the dir_a directory. (You may need to change the permissions of the directory so that you can work in it.)
  18. Rename the file bad_name.txt to warrior.txt
  19. Delete the file remove_me.txt
  20. Return to your home directory.
  21. Create a tar file compressed with bzip2 named answer.tar.bz2 which contains the hw3_files directory.
  22. Turn in the answer.tar.bz2 file.

How to submit your homework:

Follow the directions on the homework page.

How to receive negative points:

Turn in someone else’s work.

Page: Main.HW3
Modified: February 09, 2013, at 12:08 PM
Wiki: pmwiki-2.2.35
CS Department
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2012 Colorado State University