- OPS435 -


Lab #2

FOCUS: Linux Commands / BASH File Name Expansion / Redirection

PART A - Perform the following tasks:

  1. Logon to your Matrix account.
  2. Perform the week2 online tutorial called "Online Linux Tutorials". This tutorial must be completed to count as half of the mark for this lab #2. The tutorial, when properly completed will send your instructor and yourself an e-mail message to verify that the tutorial was completed.

    Here is a link to the online tutorial instructions: [ html ]

  3. Proceed to Part B

PART B - Perform the following tasks:

  1. This lab requires that you use your Matrix account in order to submit your lab.
  2. Make an empty directory, called lab02.
  3. Use the cd command to make lab02 your present working directory.
  4. Use the touch command to create the following files in the lab02 directory
    123.2 foo foo.o foo2 foobar fooey
    123.foo foo.bar foo1 fooa foobar.12
    456 foo.c foo12 foobam foobar12

  5. Open an editor (vi or gedit) and answer the following questions displayed below.
    The name of your file should be called lab02.txt.

    For each question (a-n), write the exact output and enter it as a line as your answer. Just write the output, don't number or place letters in front of the answer or place anything other than the expected output. If you think that the command generates an error message, you do NOT include that error message in your answer.

    Do not use the shell prompt to issue the command, try to figure it out yourself first.

    NOTE: When typing the results from these commands in your lab02.txt file,
    make certain to separate each of your answers by a single empty line...
    1. ls foo*bar
    2. ls foo.[cho]
    3. ls foo*.[!c]
    4. ls foo[!a-z][!a-z]
    5. ls *foo*
    6. ls foo*[0-9][0-9]
    7. ls [!crl]*.*
    8. ls ???
    9. ls [a-z]*[0-9]
    10. ls [0-9]*[0-9]
    11. ls [0-9]?*[0-9]
    12. ls [a-z]??[a-z]
    13. ls ?
    14. ls foo??
  6. Save and exit your file called lab02.txt, and proceed to Part C.

PART C - Perform the following tasks:
  1. Make certain that you are currently located in the lab02 directory
  2. Create a portable bash shell script called commands.bash
  3. Have your shell script execute all 14 commands that you used to answer in Part B.

  4. Add executable permissions to your shell script (chmod u+x commands.bash),
    and run your shell script to view the results.
    ( Note: if the output goes "off" the screen, issue your shell script with a pipe
    to the more command to allow you to display all of the contents... )

    (for example: ./commands.bash | more)

  5. Edit your commands.bash file to include the echo command (with no arguments)
    between each of the 14 commands in your shell script in order to have a single empty line
    separating each command result(s).

  6. Run the pipeline command: ./commands.bash | more again to see if the results
    match your results in your file called lab02.txt

  7. Issue your shell script commands.bash and use redirection to store the standard output (stdout)
    in a file called results.txt in your current directory.

  8. Use the diff command to compare the two files in your current directory called lab02.txt and results.txt.
    If you everything correct, there should be no standard output.

    NOTE: You may get frustrated because the diff command will show some differences. This could be caused by you putting "spaces" in your lab02.txt file, or you made an error in your anticipated output. Use the command
    "od -c lab02.txt | more" to view both visable and invisable characters (like space).

    If there is standard output, use that information to edit the first file (argument) to make identical to the second file (argument).

PART D - Submit your Lab #2:
  1. Make certain that you are currently located in the lab02 directory
  2. Issue the following Bash Shell script to check and if correct, send e-mail to your OPS435 professor
    (works only for Murray Saul's sections):


    This shell script should either indicate problems and hints for you to correct your shell script, or indicate that your lab #2 submission was successful. If your lab was successfully submitted, both you and your OPS435 professor (Murray Saul) should have received an e-mail message.

    Note: Keep this e-mail message for the remainder of the semester as date and time stamp proof that you submitted the lab in case there is a discrepancy with your OPS435 lab grade...