Distributed Networks Distributed Networks





Unix Concepts   «Prev  Next»

Unix Pattern Matching - Quiz


Each question is worth one point. Select the best answer or answers for each question.
 
1. Which of the following regular expressions will match the pattern exp only at the beginning of a line?
Please select the best answer.
  A. \^exp
  B. ^exp
  C. exp$
  D. exp^


2. Which of the following commands uses correct syntax for matching the patterns bunk or bank at the end of a line of text?
Please select the best answer.
  A. grep 'b[au]nk$' myfile
  B. grep "b[au]nk$" myfile
  C. grep b[au]nk$ myfile
  D. grep 'b[au]nk$" myfile

3. Suppose you want to search for this regular expression:
Please select the best answer.
  A. grep A 'stop!' sign myfile
  B. grep 'A 'stop\!' sign' myfile
  C. grep "A 'stop\!' sign" myfile
  D. grep "A 'stop!' sign" myfile


4. Which of the following meanings can a $ character assume within a regular expression?
Please select all the correct answers.
  A. A literal dollar sign
  B. Shell variable syntax
  C. End-of-line anchor for pattern matching
  D. Match any single character