INFO1211 Assignment Question

INFO 1211

ASSIGNMENT 2

Answer the following questions, using books and/or reliable sources from the Web. Do not merely copy and paste text; all answers should be in your own wording. Include references to your sources in your answers. Please word process and proofread your answers before submitting them.

Note that copying and pasting an answer from a reference, or handing in the same answer as another student is considered plagiarism and/or cheating, and will result in a zero for the entire assignment. Answers must be in your own words!

The Shell (Bash Shell)

  1. [20 points, 5 points for each question] Devise wild-card patterns to match the following filenames:
    1. foo1, foo2, and Foo5
    2. c, quit.oand quit.h
    3. htm, watch.HTML, andWatch.html
    4. all filenames that begin with a dot and endwith.swp
  2. [10 points] Explain the significance of single- and double-quoting, including when one is preferred to the other. What are the two consequences of using double quotes?
  3. [5 points] How will you add the tags <html> and </html> to the beginning and end of file foo.html using just one command line? [hint: Section 6.62 of Your Unix/Linux book]
  4. [10 points] How do you remove from the current directory all ordinary files that:
    1. [5 points] have numerals as the first three characters,
    2. [5 points] containing 2004 as an embedded string except at the beginning or end.
  5. [5 points] Given your directory contains three files fln1, fln* and flnt. How can you remove a file with name of fln* ?
  6. [10 points] How will you store in a variable count
    1. [5 points] The total size of all C source files (extension .c)
    2. [5 points] The total number of lines in test.c file
  7. [5 points] What command could you use to determine the number of files are in the /usr/bin directory?[hint: ls and wc]
  8. [5 points] Suppose that initially, there is no file in the current directory named "newfile". Will "newfile" appear after the execution of the following command?
  9. ls -l >newfile

    Explain why or why not?

Filters / grep / sed

  1. [10 points] Study by yourself about headand tail in Section 9.6 and 9.7 of the Your Unix/Linux book and answer the following questions.
  2. Give a single pipeline, using the head and the tail commands to:

    1. [5 points] select lines 5 to 10 from a file
    2. [5 points] select second-to-last line (i.e. the line before the last line) from a file
  3. [5 points] How do you list the ordinary files in your current directory that are not user-writable?
  4. [5 points] Write a command to display all the lines in a filefoo that end with a “;” or a “.” character.
  5. [5 points] Write a command to change all <B> and </B> in file htmlto <STRONG> and </STRONG>, respectively.
  6. [5 points] Write a command to use sed to print all lines in foo that beginning and ending with a dot.

Answer Detail

Get This Answer

Invite Tutor