Docstoc

Assignment 1 - DOC

Document Sample
Assignment 1 - DOC Powered By Docstoc
					Name ________________________________________________________________
CIS 52
                                      Assignment 2
                  Part 1 – Chapter 4 Discovery Exercises pages 210-211
                  Part 2 – Chapter 5 Discovery Exercises pages 268-269


  Chapter 4

  1. How can you create a file called history by using a redirection operator?

  2. Wait one minute or more and then change the time stamp on the history file you just
     created.

  3. Back up the history file to the file history.bak.

  4. Sort the corp_phones1 file by the last four digits of the phone number

  5. Create and use a command that displays only the last names and telephone numbers
     (omitting area code) of people in the corp_phones2 file. Place a space between the
     telephone number and the last name.

  6. Assume you have a subdirectory named datafiles directly under your current working
     directory, and you have two files named data1 and data2 in your current directory. What
     command can you sue to copy the data1 and data2 file from your current working
     directory to the datafiles directory?

  7. Assume you have four files: acccounts1, accounts2, accounts3, and accounts4. Write
     the past command that combines these files and separates the fields on each line with a
     “/” character, displaying the results to the screen.

  8. How would you perform the action in Exercise 7, but write the results to the file
     total_accounts?

  9. Assume you have 10 subdirectories and you want to locate all files that end with the
     extension “.c”. What command can you use to search all 10 of your subdirectories for
     this file?

  10. After you create a script file, what are the next steps to run it?

  11. Change the awk script that you created earlier so that the column headings are “Vendor”
      and “Product” and the name of the report is “Vendor Data.”


  12. Create the subdirectory mytest. Copy a file into your new subdirectory . Delete the
      mytest subdirectory and its contents using one command.

  13. Use the cut command to create a file called descriptions that contains only the product
      descriptions from the products file you created earlier in this chapter.

  14. You are worried about copying over an existing or newer file in another directory when
      you use the move command. What are your options in this situation?
Name ________________________________________________________________
CIS 52
  15. What command enables you to find all empty files in your source directory?

  16. How can you find all files in your home directory that were modified in the last seven
      days?

  17. How can you put the contents of each line of the product1 file side by side with the
      contents of the product2 file, but with only a dash between them instead of a tab?

  18. Make a copy of the corp_phones2 file and call it testcorp. Next, create a single-line
      command that enables you to cut characters in the fifth of the testcorp file and paste
      them back to the first column in the same file. (hint: two good solutions exist, one in
      which you use a semicolon and on with more finesse in which you use a pipe character.)

  19. How can you use a command you have learned in this chapter to list the names of all
      users on your system? (hint: find out the name of the file in which user information is
      stored.)

  20. Type who and press enter to view a list of logged-in users, along with other information.
      Now use the who command with a command you learned in this chapter to view who is
      logged in, but to supress all other information that normally accompanies the who
      command.

  Chapter 5

  1. Use a command to find the number of instances in which the word “host” is used in the
     /etc directory.

  2. What addition to the command you used in Exercise 1 can you use to slow the output to
     one screen at a time?

  3. How can you determine the number of lines and words in the /etc/termcap file?

  4. Use a command to remove the letters “o” and “a” from the my_list file you created in the
     Hands-on Projects – and write the output to the file changed_list.

  5. Use a command to find out which lines in the my_list file contain the word “Foot.”

  6. Create a file called trees, containing the following individual lines:
     Oak tree
     Pine tree
     Spruce tree
     Cottonwood
     Maple tree

     Use the vi editor to create a file called more_trees, and copy in the contents of the trees
     file. Next, add the following trees at the end of the list.

     Redwood
     Willow tree
Name ________________________________________________________________
CIS 52
     Use a command to compare the trees and more_trees files and that outputs the
     differences in columns.

  7. Use a command to compare the trees and more_trees files and show the differences in
     terms of individual lines that differ.

  8. Determine the number of bytes in both the trees and more_trees files using a one-line
     command.


  9. Use a command to replace the word “tree” with “plant” in the more_trees file and display
     the output to the screen.

  10. Create a new file, CD_list, and enter these lines in the file:
      country:1000:210
      rock:1001:380
      classical:1002:52
      alternative:1003:122
      light rock:1004:151
      light rock:1004:151
      celtic:1005:44
      jazz:1006:62
      soundtracks:1007:32
      soundtracks:1007:32

     Use the sed command and a script file to add these lines to the end of the CD_list file:

     hard rock:1008:70
     misc:1009:22

  11. Use a command to find the duplicate lines (records) in the CD_list file.

  12. Use the uniq command to remove the duplicate lines in the CD_list file, placing the
      corrected information in a file called CD_list_new.

  13. In the CD_list_new file, replace the word “misc” with “other,” save the changes in the file
      CD_list_replace, and then compare the contents of the CD_list file with the
      CD_list_replace file to ensure your changes are implemented.

  14. Use the grep command to find all the lines that contain the word “celtic” in the
      CD_list_new file.

  15. Use a command to make all letters uppercase in the CD_list_new file and save the
      output to a file called CD_list_uppercase.

  16. Use the sed command on the CD_list_new file to replace the words “light rock” with
      “easy listening” and the word “alternative” with “experimental.”


  17. Create a file called software with these fields:
Name ________________________________________________________________
CIS 52
     *Project Number, using the same numbers show in the project file (which you created
     earlier in this chapter)
     *Software Code, using any three-digit number
     *Software Description, such as Excel

     Then write a small application joining records in the software file to matching records in
     the project file, and use the Awk program to print a report describing the software for
     each project you created earlier.

  18. View the first 20 lines of /etc/termcap. Next use a command to change all characters in
      “version” to uppercase for only the first 20 lines in /etc/termcap.

  19. Find a command to compare the differences between three files and that creates output
      for individual lines.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:357
posted:11/3/2011
language:English
pages:4