Week 6 Tutorial Exercises

  1. What will be matched by the following regular expressions?
    1. x*
    2. xx*
    3. [0-9]
    4. [0-9]*
    5. [0-9][0-9][0-9]
    6. ^\...
    7. [A-Za-z_][a-zA-Z_0-9]*
    8. ^Begin$
    9. ^\(.\).*\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. date | cut -c 12-16
  3. Write the commands to:
    1. Find all logged in users with user names of at least 6 characters
    2. Find all users on your system whose user ids are greater than 99 (Hint: user ids are the third field in the file /etc/passwd)
    3. Find the number of users on your system whose user ids are greater than 99
  4. What will be the effect of the following command
    
        sed 's/\([Uu]nix\)/\1(TM)/g' text > text.out
      
    if the file text contains the line
    "The Unix operating system was pioneered by Ken Thompson"