| sed script | stack commands | listcommands shellscript | bash startup file on RCS | awk itar |
There are 5 problems listed below - you need to do 3 of them. The grade for the 3 problems you pick will be your grade for HW3 and for TEST #2 (as discussed in class).
We will only grade 3 problems! All questions have equal weight in grading.
You need to write an sed script that will extract the
title from an HTML document (HTML details shown below).
Your script must be submitted as a file (not as a sample command
line)! The file should be named gettitle and the contents
of the file should be an sed script. This is not a shell script - you
cannot use anything except sed! For example, here is a
sample sed script:
#!/bin/sed -nf # Here is my script it prints all lines with the word HI /HI/p
Note that the complete path to sed may be different on different
machines (it might be
To complete this problem you need to understand a little about HTML files. HTML files are text files that contain tags that are used (by a web browser) to control the display of the document. For example you can use tags to tell the browser that a chunk of text should be drawn in boldface.
Each HTML tag is contained within the characters
This is normal text. <B>This text should be bold</B> <I>This text should be italics</I>
Notice that there is a start tag for bold:
The title of an HTML document is found between the start and end tags
HTML tags can have whitespace inside them (the tag name itself cannot contain whitespace, but there can be whitespace between the < and the tag name, etc). HTML tag names can be any mixture of upper and lower case! These are all legal HTML titles: <TITLE>My Title</TITLE> < TITLE >Another document name < /TITLE> <Title>blah</TITLE> < title>Foo Foo Foo < /TiTLE> When you visit a web page the HTML title is usually displayed on the titlebar of the browser window (Netscape and IE both do this). You can save the document with the "save as" menu item in the file menu, and then run your sed script giving the script the name of the HTML file as a command line argument. Assuming the file samp.html
contains title tags that surround the string This is a sample
document, running your script might look like this:
> ls samp.html foo.html joe.html > gettitle samp.html This is a sample document >
|
This problem involves the creation of 2 new commands using whatever
means you want (shell scripts, awk scripts, bash functions,
whatever...). The two new commands are push and
pop and together they implement a simple stack
where you can store simple strings.
Stack A stack is a list in which whatever goes in last
comes out first. The
Some Issues:
|
For this problem you need to write a shell script that prints out
a sorted list of all the commands available at the unix prompt. You do
not need to list shell internal commands, aliases or functions. You
should simply use the PATH environment variable to find
all executable files in your path.
The output of this command (name the shell script
"
|
| This one is for those who don't want to write code! Your job is to find the the system-wide shell startup file for bash on RCS, and to document (explain) all the commands in this file. Finding the file should not be difficult (try "man bash" !), but you will probably need to spend some time figuring out what the commands in the file actually do!. I expect a detailed explaination of everything in the startup file - not broad, general statements. |
itar
I want the itar command from
HW2, but this time you must
write it completely in awk!
|