COP 2344 (Shell Scripting) Project #2
Regular Expressions

 

Due: by the start of class on the date shown on the syllabus

Description:

Answer the following questions as briefly (but completely) as possible.  (These are thought exercises.  You are not supposed to type them in, but you can later, to check your answer after you have thought about it.)

Questions:

  1. What will be matched by the following regular expressions?  (Assume POSIX locale.)
    1. x*
    2. [0-9]\{3\}
    3. xx*
    4. [0-9]\{3,5\}
    5. x\{1,5\}
    6. [0-9]\{1,3\},[0-9]\{3\}
    7. x\{5,\}
    8. ^\...
    9. x\{10\}
    10. [A-Za-z_][A-Za-z_0-9]*
    11. [0-9]
    12. \([A-Za-z0-9]\{1,\}\)\1
    13. [0-9]*
    14. ^Begin$
    15. [0-9][0-9][0-9]
    16. ^\(.\).*\1$
  2. What will be the effect of the following commands?
    1. who | grep 'mary'
    2. who | grep '^mary'
    3. grep '[Uu]nix' ch?/*
    4. ls -l | sort -k 5nr
    5. sed '/^$/d' text > text.out
    6. sed 's/\([Uu]nix\)/\1(TM)/g' text > text.out
    7. date | cut -c12-16
    8. date | cut -c5-11,25- | sed 's/\([0-9]\{1,2\}\)/\1,/'
  3. Write commands to
    1. Find all logged-in users with usernames of at least four characters.
    2. Find all users on your system who's user ids are greater than 99.
    3. Find the number of users on your system who's user ids are greater than 99.
    4. List all the files in your current directory in decreasing order of file size (without using the “-S” option to ls).

To be turned in:

The answers to the above questions.  Where appropriate feel free to use the script command to record your sessions.  See the man page for script for more details.  Then you can email to me the resulting typescript file created.

You can type or send as email to .  Please use the subject similar to “Shell Scripting Project Submission”, so I can tell which emails are submitted projects.

Send questions about the assignment to .  Please use a subject similar to “Shell Scripting Project Question” so I can tell which emails are questions about the assignment (and not submissions).

Please see your syllabus for more information about submitting projects.