Utah Tech Logo

IT3300

DevOps virtualization

Lab 11

Part I

Begin by downloading this file to scratch (use wget).

For each task, you should start with the downloaded file and use awk to parse the file. Everything should be done as a single command (without using intermediate files, or ;, or &&). You probably will always use the pipe | or multiple pipes.

Create a directory in your $HOME called lab11. This directory will contain out1.txt - out13.txt when completed. There is an autograder for this lab.

For all examples I have listed only the first 3 lines of the new output but your files should contain all of the output.

  1. Print out only the hostnames and redirect the output to out1.txt.

      dickson 
      robinson
      niven
    
  2. Using awk and sort, print out the hostnames in alphabetical order and redirect the output to out2.txt.

      adams
      anson
      asimov
    
  3. Print out the string port ‘port number’ is attached to host ‘hostname’. (Make sure it is pulling hostname and port from the file) and redirect the output to out3.txt

     port Gi6/37 is attached to host dickson
     port Gi6/38 is attached to host robinson
     port Gi6/47 is attached to host niven 
    
  4. Print out only the mac addresses. (Hint: I used awk awk to remove the semicolon.) and redirect the output to out4.txt.
     10:dd:b1:db:db:2d
     c8:2a:14:3f:9d:41
     c8:2a:14:3f:a8:e0 
    
  5. Print the file in the following format and redirect the output to out5.txt.

     dickson 144.38.195.239
     robinson 144.38.195.253
     niven 144.38.195.249
    
  6. Now reverse and print out the ip’s:(note that 144.38.195.239 in reverse would be 239.195.38.144) and redirect the output to out6.txt. (Hint: awk to split on whitespace, awk to split on ‘;’, awk to split on ‘.’. Don’t forget to add the ‘.’ back in.)

      239.195.38.144
      253.195.38.144
      249.195.38.144
    
  7. Do the exact same as the last one, except instead of printing the ip with the ‘.’s in between, add the numbers up and redirect the output to out7.txt.

      616
      630
      626
      625
    

Part II

Use sed. Use the same downloaded file for Part II.

  1. Print every other line in the file (starting with the second line) and redirect the output to out8.txt.

  2. Delete the first line from the file and redirect the output to out9.txt.

  3. Replace every occurance of the word ‘host’ with ‘computer’ and redirect the output to out10.txt.

  4. Print only the 5-8th lines and redirect the output to out11.txt.

Part III

  1. Remove the # and everything that follows from each line (use regular expression and sed search/replace) and redirect the output to out12.txt.

  2. Print only lines 20-30 from the file and only the second and eighth columns, remove the semicolon. Search for and replace the ‘24’ and everything that comes before it with ‘removed’. Redirect the output to out13.txt.

    card 144.38.195.234
    decamp 144.38.195.238
    clarke 144.38.195.235
    dahl 144.38.195.237
    crichton 144.38.195.236
    burroughs 144.38.195.233
    removed0
    removed1
    removed7
    

The grading script will be run as you are logged into scratch. The command you will execute will be similar for all of your assignments that have an autograder. Here is a sample of the command you will run: `run_grader.py –n 2. The 2 is representative of lab2. (Lab 3 would replace the 2 with a 3). Please see your instructor for any help or questions on the output.