Q: 1. Create a file called "exercise05answers.txt"
touch exercise05answers.txt
Q: 2. At the top of the file, use the label as defined before.
as before
Q: 3. Put on a line the word "lab" by itself, then work on lab exercises 1-10 below. List all the relevant commands and arguments that you had to use in the lab exercises. Put in comments to show why you did something (this can help your mark even if you did something wrong).
in sequence
  1. In my directory on the course linux server (my username is "gj"), is a directory called "public_html/dropbox". In this location, create a directory the name of which is your studentid. Set the permissions on this directory to only allow yourself all permissions (i.e. make sure that nobody else on the system can get into this directory). From here on, all lab exercises should take place in the directory you have just created (i.e. any new files you create have to go in there).
    # go to the directory, so I don't have to type so much
    cd ~gj/public_html/dropbox/
    # create directory, where my studentid is 01234567890
    mkdir 01234567890
    # set the permissions as indicated with chmod
    chmod 700 01234567890
    #go to the directory
    cd 01234567890
  2. Create a file called "firstlast", the contents of which are the first and the last line of the password file. Do not use an editor.
    head -1 /etc/passwd > firstlast
    tail -1 /etc/passwd >> firstlast
  3. Create a file called "firstmore", the contents of which are the contents of firstlast. Add to that the current date.
    cp firstlast firstmore
    date >> firstmore
  4. Use the command "wget" to retrieve weather information from here:
    and drop it into a file called "weatherforecast". You may want to look in a "normal" browser first, so that you have an idea of the information that you are getting.
    wget 'http://text.weatheroffice.ec.gc.ca/forecast/textforecast_e.html?Bulletin=fpcn12.cwao&b_templatePrint=true'
    mv textforecast* weatherforecast
  5. Create a file "weathertable.txt" that starts with "Canadian urban forecasts issued 2006/02..." (so this is the first line), and the last line is the forecast for the last city on the web page. This file should not contain any HTML code.
    grep -v '<' weatherforecast | grep '[a-z]' > weathertable.txt
  6. Create a file called "ottawaweather.txt" that contains only the forecast for Ottawa.
    grep Ottawa weathertable.txt > ottawaweather.txt
  7. How would you create "ottawaweather.txt" if you could not create temporary files, but had to parse the wget information immediately?
    wget -O - 'http://text.weatheroffice.ec.gc.ca/forecast/textforecast_e.html?Bulletin=fpcn12.cwao&b_templatePrint=true' | grep Ottawa > ottawaweather.txt
  8. The extended forecast can be found at this URL
    Drop the web page into a file called "weatherlong".
    wget -O weatherlong http://text.weatheroffice.ec.gc.ca/forecast/textforecast_e.html?Bulletin=fpcn51.cwto&b_templatePrint=true
  9. Create a file "ottawaextended.txt" that contains the last paragraph of the weather information, without HTML code. What would happen if the order of the locations in this forecast would change?
    grep -v '>' weatherlong | tail -10 > ottawaextended.txt
    If the order of the locations changes, the file ottawaextended.txt will not contain the forecast for Ottawa.
  10. (bonus) Are there new options to grep that would help pinpoint the Ottawa information? What command pipeline will work, regardless of the order of the locations in the forecast?
    grep -v '>' weatherlong | grep -A 10 Ottawa > ottawaextended.txt
    Q: 7. Submit using the datsubmit command
    datsubmit 05 exercise05answers.txt