Tutorial Exercises Week 4

  1. Given the following files in your current directory:

    $ ls
    feb90
    jan12.91
    jan19.91
    jan26.92
    jan5.93
    jun87
    jun88
    jun89
    jul89
    jul93
    mar93
    memo1
    memo10
    memo2
    memo.dat
    $
          
    What would be the output from the following commands?
    1. echo *
    2. echo m[a-df-z]*
    3. echo jan*
    4. echo ?????
    5. echo [jm][au][nr]*
    6. echo *[!0-9]
    7. echo [A-Z]*
    8. echo *.*

  2. Which of the following are valid variable names?

    XxXxXx
    12345
    file.name
    file_name
    file1
    _
    HOMEDIR
    _date
    x0-9
    Slimit
          

  3. Suppose your HOME directory is /usr/person and that you have subdirectories as shown below:

    Assume you have just logged into the system and typed the following commands:

    $ docs=/usr/person/documents
    $ let=$docs/letters
    $ prop=$docs/proposals
    $ prog=/usr/person/programs
          
    Write the commands in terms of these variables to:
    1. List the contents of the documents directory
    2. Copy all files from the letters directory to the proposals directory.
    3. Move all files whose names contain a capital letter from the letters directory to the current directory.
    4. Count the number of files in the memos directory.
    What would be the effect of the following commands?
    1. ls $let/..
    2. cat $prop/sys.A
    3. echo $let/*
    4. cp $let/ask.ALP $prog
    5. cd $prop