- 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
# create directory, where my studentid is 01234567890
# set the permissions as indicated with chmod
chmod 700 01234567890
#go to the directory
- 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
- Create a file called "firstmore", the contents of which
are the contents of firstlast. Add to that the current
cp firstlast firstmore
date >> firstmore
- Use the command "wget" to retrieve weather information
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.
mv textforecast* weatherforecast
- 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
grep -v '<' weatherforecast | grep '[a-z]' > weathertable.txt
- Create a file called "ottawaweather.txt" that contains
only the forecast for Ottawa.
grep Ottawa weathertable.txt > ottawaweather.txt
- How would you create "ottawaweather.txt" if you could
not create temporary files, but had to parse the wget
wget -O - 'http://text.weatheroffice.ec.gc.ca/forecast/textforecast_e.html?Bulletin=fpcn12.cwao&b_templatePrint=true' | grep Ottawa > ottawaweather.txt
- 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
- 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.
- (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
grep -v '>' weatherlong | grep -A 10 Ottawa > ottawaextended.txt
- Q: 7. Submit using the datsubmit command
A: datsubmit 05 exercise05answers.txt