sed scripts are not playing nicely!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed scripts are not playing nicely!
# 1  
Old 06-29-2010
sed scripts are not playing nicely!

I am having a lot of trouble, wasting a lot of time trying to get sed script files to run without problem. I have a list of scripts I want to run on a text file to turn it into a viewable html file for my mobile phone. Each of the single scripts when run in order/sequence one after another on the command line work fine. I end up with the file I want to view on my phone's browser. Then I put the sed scripts into a file enclosed in curly brackets (top and bottom as expected) without anoything other than the actual sed script (no sed command, no sed options, no surrounding quotes around the sed script). When I apply this file to a text file, the same file I applied all of the scripts one at a time on the command line and worked fine, the scripts do not all seem to get applied.

Perhaps I am wrong in my assumption that sed works line by line and makes changes before moving to the next line until the end of the file is reached, afterwhich the next sed script is read and sequentially applied to each of the lines in the text file, in which some of the lines have been altered by the previous sed script in the script file? If that is not the case then that must be where I am getting hung up assuming some lines in the text file to be altered from previous sed scripts in the script file.

This problem is enough to drive me to drink. Some script lines seem to run while other just do nothing, unless of course run one at a time from the command line.


As an example, here is a chunk from the script file I am trying to apply to text files:

Code:
#reformat line numbers onto their own lines and delete all lines not ending with a zero or five
    s/^.*[1-4]   \(.*\)$/\1/g
    s/^.*[6-9]   \(.*\)$/\1/g
#    s/^\([0-9]*\)   \([A-Za-z']\)/<tr><td>\1<\/td><\/tr>\n\2/g
    s/^\([0-9]*\)   \([A-Za-z']\)/\1\n\2/g
            
#HTML TAG SECTION
    s/^\(25\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g

After filtering out all line numbers other than ones ending with zero or five, and put them onto their lines (which all works fine from applying the script file) then the first sed script that follows to enclose applicable HTML tags and make the line number 25 a hyperlinked reference (for easy navigation while being viewed on my phone) does not get applied.

However, if I run this line:

Code:
$ sed -i 's/^\(25\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g' textFile.txt

the line that starts and ends with the number 25 gets the HTML tags applied as desired.

If anyone can help me out and show me the error of my ways with using sed script files (my commands all work fine on their own) you might just help save my liver in time!

cheers,
tt
# 2  
Old 06-29-2010

I have 2 suggestions:

1. Use awk, not sed

2. Provide sample input and desired output
# 3  
Old 06-29-2010
Quote:
1. Use awk, not sed
Hi cfaj,

I know there are better tools for doing what I want to achieve, however, I am not a programmer and my time is very limited. I feel comfortable enough with sed at the command line and can get most of what I want done hacking around with sed. But with so many sed commands to run for this little project I thought a script file would be a perfect timesaver, but is now turning into a huge time sync and headache, but well worth the effort if I can get things to run as desired.

So for this example I have an act and scene from a Shakespeare play I want to make readable, but not a resource hog for my aging mobile phone (I have tried viewing stright up HTML files on my phone but they are resource pigs and scroll so slowly, so my basic HTML reformatting makes reading/scrolling much nicer).

I am including snippets from all files to show before-sed script-desired results (that I have yet to achieve from the script file).

Shakespeare snippet:
Quote:
SLY
13 Third, or fourth, or fift borough, I'll answer him
14 by law: I'll not budge an inch, boy: let him come,
15 and kindly.

[Falls asleep.]

Wind horns. Enter a LORD from hunting, with his TRAIN.

LORD
16 Huntsman, I charge thee, tender well my hounds:
17 Brach Merriman, the poor cur is emboss'd;
18 And couple Clowder with the deep-mouth'd brach.
19 Saw'st thou not, boy, how Silver made it good
20 At the hedge-corner, in the coldest fault?
21 I would not lose the dog for twenty pound.

FIRST_HUNTSMAN
22 Why, Belman is as good as he, my lord;
23 He cried upon it at the merest loss
24 And twice today pick'd out the dullest scent:
25 Trust me, I take him for the better dog.

LORD
26 Thou art a fool: if Echo were as fleet,
Here I need to 1) delete all empty/blank lines; 2) get rid of all line numbers except ones that end with a fiver or zero; 3) and every 25th line make a hyperlinked anchor point for easy page navigation in my phone.

So here is what I have sofar for my sed script file to take care of the requirements mentioned above. Of course there is much yet to be added to this file to get the page totally formatted the way I want, but this is where I am stuck so no use in moving ahead, yet.

Code:
{

#REMOVE ALL UNWANTED WHITESPACE, BLANK LINES, TEXT, OR ANYTHING ELSE THAT MUST GO SECTION
		#delete all blank lines
	/^$/d
		#rm all beginning and trailing whitespace followed by all blank lines
	s/^[ \t]*//g
	s/[ \t]*$//g
		#remove an uwanted escaped return chars that will prevent the next line from applying correctly
	s/\r//g 

#SUBSTITUTION SECTION
		#subst. long hyphen with two dashes
	s/-/--/g
		#subst. single quote for proper single quote
	s/'/'/g
		#next two lines subst. improper double quotes for proper
	s/”/"/g
	s/“/"/g

#reformat line numbers onto their own lines and delete all lines not ending with a zero or five
	s/^.*[1-4]   \(.*\)$/\1/g
	s/^.*[6-9]   \(.*\)$/\1/g
#	s/^\([0-9]*\)   \([A-Za-z']\)/<tr><td>\1<\/td><\/tr>\n\2/g
	s/^\([0-9]*\)   \([A-Za-z']\)/\1\n\2/g
			
#HTML TAG SECTION
	s/^\(25\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(50\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(75\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(100\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(125\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(150\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(175\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(200\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(225\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(250\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(275\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(300\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(325\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(350\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(375\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(400\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(425\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(450\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(475\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^\(500\)$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
		#add hyperlinks to line numbers in denominations of 25 #DOES NOT WORK!!!!!!!!!!
	#/0<\/td>/s\(<tr><td>\)\(.*\)\(<\/td><\/tr>\)/\1<a href="#\2Top" name="\2"><u><b>\2<\/b><\/u><\/a>\3/g
	s/^<tr><td>\(25\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(50\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(75\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(100\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(125\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(150\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(175\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(200\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(225\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(250\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(275\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(300\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(325\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(350\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(375\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(400\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(425\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(450\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(475\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
	s/^<tr><td>\(500\)<\/td><\/tr>$/<tr><td><a href="#\1Top" name="\1"><u><b>\1<\/b><\/u><\/a><\/td><\/tr>/g
		#enclose any lines with names in UPPERCASE in bold tags
	s/^\([A-Z_]\{,20\}\)$/<tr><td><b>\1<\/b><\/td><\/tr>/g
		#eclose any lines with sq. brackets already in bold
	/^\[.*\]/s/\(\[.*\]\)/<tr><td><b>\1<\/b><\/td><\/tr>/g
		#enclose all lines of action in bold and sq. brackets
	/Enter/s/^\(.*\)$/<tr><td><b>\[\1\]<\/b><\/td><\/tr>/g
	/Exit/s/^\(.*\)$/<tr><td><b>\[\1\]<\/b><\/td><\/tr>/g
		#enclose all lines beginning with numbers in tags
	
	
}

Once again, I am absolutely convinced there are better, more appropriate tools to accomplish what I want, but presently and for the forseeable future sed is the tool I have at my disposal, which should be able to take care of my requirements once I figure out why things are not running in the script file as I expect.

The end result should look like:
HTML Code:
<tr><td><b>SLY<\/b><\/td><\/tr>
Third, or fourth, or fift borough, I'll answer him
by law: I'll not budge an inch, boy: let him come,
<tr><td>15<\/td><\/tr>
and kindly.
<tr><td><b>[Falls asleep.]<\/b><\/td><\/tr>
<tr><td><b>[Wind horns. Enter a LORD from hunting, with his TRAIN.]<\/b><\/td><\/tr>
<tr><td><b>LORD<\/b><\/td><\/tr>
Huntsman, I charge thee, tender well my hounds:
Brach Merriman, the poor cur is emboss'd;
And couple Clowder with the deep-mouth'd brach.
Saw'st thou not, boy, how Silver made it good
<tr><td>20<\/td><\/tr>
At the hedge-corner, in the coldest fault?
I would not lose the dog for twenty pound.
<tr><td><b>FIRST_HUNTSMAN<\/b><\/td><\/tr>
Why, Belman is as good as he, my lord;
He cried upon it at the merest loss
And twice today pick'd out the dullest scent:
<tr><td><a href="25Top" name="25"><u><b>25<\/b><\/u><\/a><\/td><\/tr>
Trust me, I take him for the better dog.
<tr><td><b>LORD<\/b><\/td><\/tr>
Thou art a fool: if Echo were as fleet,
Like I said, with more sed scripts req'd to finish the desired formatting, but that is how it should look with the sed script at the point I pasted above.


I also noticed looking at a preview, a few lines in the sed script that are there as a result of trying a few different things to get things working nicely, so I hope they are not confusing. They should be fairly easy to follow I think?

thanks again,
tt
# 4  
Old 06-29-2010
Quote:
Originally Posted by naphelge
The end result should look like:
HTML Code:
<tr><td><b>SLY<\/b><\/td><\/tr>
Third, or fourth, or fift borough, I'll answer him
by law: I'll not budge an inch, boy: let him come,
<tr><td>15<\/td><\/tr>
and kindly.
<tr><td><b>[Falls asleep.]<\/b><\/td><\/tr>
<tr><td><b>[Wind horns. Enter a LORD from hunting, with his TRAIN.]<\/b><\/td><\/tr>
<tr><td><b>LORD<\/b><\/td><\/tr>
Huntsman, I charge thee, tender well my hounds:
Brach Merriman, the poor cur is emboss'd;
And couple Clowder with the deep-mouth'd brach.
Saw'st thou not, boy, how Silver made it good
<tr><td>20<\/td><\/tr>
At the hedge-corner, in the coldest fault?
I would not lose the dog for twenty pound.
<tr><td><b>FIRST_HUNTSMAN<\/b><\/td><\/tr>
Why, Belman is as good as he, my lord;
He cried upon it at the merest loss
And twice today pick'd out the dullest scent:
<tr><td><a href="25Top" name="25"><u><b>25<\/b><\/u><\/a><\/td><\/tr>
Trust me, I take him for the better dog.
<tr><td><b>LORD<\/b><\/td><\/tr>
Thou art a fool: if Echo were as fleet,

That's not anything close to valid HTML, even after removing the extra backslashes. (http://cfajohnson.com/testing/bard.html)

Try posting something that looks reasonably like the rendered HTML you want rather than the source code. I'm sure it can be done with no more than half a dozen lines in awk.

Last edited by cfajohnson; 06-29-2010 at 11:04 AM..
# 5  
Old 06-29-2010
Quote:
Originally Posted by cfajohnson

That's not anything close to valid HTML, even after removing the extra backslashes. (http://cfajohnson.com/testing/bard.html

Try posting something that looks reasonably like the rendered HTML you want rather than the source code. I'm sure it can be done with no more than half a dozen lines in awk.
I am unsure if you are just hard of reading or just a crusty old fart that feels he is obligated to shove his ideas down the throats people seeking help.

Yeah, ok I asked for help, but I already said I was not interested in using another tool that is likely better suited than SED to accomplish the task at hand, since I am already comfortable using SED, my time is extremely limted, and I know SED can do what I need it to do, albeit likely with added lines of code, something I am willing to live with.

Yeah, ok I also know the snippets I included were not "valid" HTML, but if you read my post you would have read what I was pasting was the result of the SED script file "thus" far, and that more SED scripts would be required to get the page finally formatted so that it would render properly in a browser (specifically the one on my aging phone).

I appreciate the fact that you come here and attempt to provide helpful advice, but instead of preaching, why do you not just answer question(s) asked if you really want to help.

Lucky, for me someone at the Ubuntu forums answered the question I aksed, without feeling the need to suggest other applications that are likely better suited to the task at hand. Instead, with the question being answered, I realized where I was going wrong, made the necessary adjustments and have since moved on to complete my SED script file that is now reformatting the text files I have to HTML code (with a couple of minor bugs that are easily fixed). Period.

BTW, the problem I was making was assuming SED was applying changes to each line as it was being processed, and so any line where I inserted a newline '\n' to split lines was treating as two separate lines instead of a single line like I should have been doing.

Pretty simple, huh?

and here is the finished HTML code, that I am sure is still not valid according some formal HTML coding rules, but it is good enough for rendering correctly on my phone.

HTML Code:
<html>
<head>
<style>
body { font-family: Arial, Verdana, Tahoma; }
.just { text-align: justify; }
.padleft3 { padding-left: 3; }
.padleft6 { padding-left: 6; }
.padleft9 { padding-left: 9; }
.padleft12 { paddling-left: 12; }
</style>
</head>
<body>
<table class="just">
<tr><td><b>The Taming of the Shrew</b></td></tr>
<tr><td><b>by William Shakespeare</b></td></tr>
<tr><td>.</td></tr>
<tr><td><a href="#1" name="1Top"><u><b>Goto to start of scene</b></u></a></td></tr>
<tr><td><a href="#25" name="25Top"><u><b>Goto line 25</b></u></a></td></tr>
<tr><td><a href="#50" name="50Top"><u><b>Goto line 50</b></u></a></td></tr>
<tr><td><a href="#75" name="75Top"><u><b>Goto line 75</b></u></a></td></tr>
<tr><td><a href="#100" name="100Top"><u><b>Goto line 100</b></u></a></td></tr>
<tr><td><a href="#125" name="125Top"><u><b>Goto line 125</b></u></a></td></tr>
<tr><td>.</td></tr>
<tr><td><a href="#1Top" name="1"><u><b>The Taming of the Shrew: Induction, Scene 1</b></u></a></td></tr>
<tr><td>.</td></tr>
<tr><td><b>[Enter Beggar, CHRISTOPHERO SLY, and HOSTESS.]</b></td></tr>
<tr><td><b>SLY:</b></td></tr>
<tr><td><i>I'll pheeze you, in faith.</i></td></tr>
<tr><td><i>Hostess</i></td></tr>
<tr><td><i>A pair of stocks, you rogue!</i></td></tr>
<tr><td><b>SLY:</b></td></tr>
<tr><td><i>Ye are a baggage: the Slys are no rogues;</i></td></tr>
<tr><td><i>look in the chronicles; we came in with</i></td></tr>
<tr><td>5</td></tr>
<tr><td><i>Richard Conqueror. Therefore paucas</i></td></tr>
<tr><td><i>pallabris; let the world slide. Sessa!</i></td></tr>
<tr><td><i>Hostess</i></td></tr>
<tr><td><i>You will not pay for the glasses you have</i></td></tr>
<tr><td><i>burst?</i></td></tr>
<tr><td><b>SLY:</b></td></tr>
<tr><td><i>No, not a denier. Go by, Jeronimy: go to</i></td></tr>
<tr><td>10</td></tr>
<tr><td><i>thy cold bed, and warm thee.</i></td></tr>
<tr><td><b>HOSTESS:</b></td></tr>
<tr><td><i>I know my remedy; I must go fetch the</i></td></tr>
<tr><td><i>third-borough.</i></td></tr>
<tr><td><b>[Exit.]</b></td></tr>
<tr><td><b>SLY:</b></td></tr>
<tr><td><i>Third, or fourth, or fift borough, I'll answer him</i></td></tr>
<tr><td><i>by law: I'll not budge an inch, boy: let him come,</i></td></tr>
<tr><td>15</td></tr>
<tr><td><i>and kindly.</i></td></tr>
<tr><td><b>[Falls asleep.]</b></td></tr>
<tr><td><b>[Wind horns. Enter a LORD from hunting, with his TRAIN.]</b></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Huntsman, I charge thee, tender well my hounds:</i></td></tr>
<tr><td><i>Brach Merriman, the poor cur is emboss'd;</i></td></tr>
<tr><td><i>And couple Clowder with the deep-mouth'd brach.</i></td></tr>
<tr><td><i>Saw'st thou not, boy, how Silver made it good</i></td></tr>
<tr><td>20</td></tr>
<tr><td><i>At the hedge-corner, in the coldest fault?</i></td></tr>
<tr><td><i>I would not lose the dog for twenty pound.</i></td></tr>
<tr><td><b>FIRST_HUNTSMAN:</b></td></tr>
<tr><td><i>Why, Belman is as good as he, my lord;</i></td></tr>
<tr><td><i>He cried upon it at the merest loss</i></td></tr>
<tr><td><i>And twice today pick'd out the dullest scent:</i></td></tr>
<tr><td><a href="#25Top" name="25"><u><b>25</b></u></a></td></tr>
<tr><td><i>Trust me, I take him for the better dog.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Thou art a fool: if Echo were as fleet,</i></td></tr>
<tr><td><i>I would esteem him worth a dozen such.</i></td></tr>
<tr><td><i>But sup them well and look unto them all:</i></td></tr>
<tr><td><i>tomorrow I intend to hunt again.</i></td></tr>
<tr><td><b>FIRST_HUNTSMAN:</b></td></tr>
<tr><td>30</td></tr>
<tr><td><i>I will, my lord.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>What's here? one dead, or drunk? See, doth he breathe?</i></td></tr>
<tr><td><b>SECOND_HUNTSMAN:</b></td></tr>
<tr><td><i>He breathes, my lord. Were he not warm'd with ale,</i></td></tr>
<tr><td><i>This were a bed but cold to sleep so soundly.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>O monstrous beast! how like a swine he lies!</i></td></tr>
<tr><td>35</td></tr>
<tr><td><i>Grim death, how foul and loathsome is thine image!</i></td></tr>
<tr><td><i>Sirs, I will practice on this drunken man.</i></td></tr>
<tr><td><i>What think you, if he were convey'd to bed,</i></td></tr>
<tr><td><i>Wrapp'd in sweet clothes, rings put upon his fingers,</i></td></tr>
<tr><td><i>A most delicious banquet by his bed,</i></td></tr>
<tr><td>40</td></tr>
<tr><td><i>And brave attendants near him when he wakes,</i></td></tr>
<tr><td><i>Would not the beggar then forget himself?</i></td></tr>
<tr><td><b>FIRST_HUNTSMAN:</b></td></tr>
<tr><td><i>Believe me, lord, I think he cannot choose.</i></td></tr>
<tr><td><b>SECOND_HUNTSMAN:</b></td></tr>
<tr><td><i>It would seem strange unto him when he waked.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Even as a flattering dream or worthless fancy.</i></td></tr>
<tr><td>45</td></tr>
<tr><td><i>Then take him up and manage well the jest:</i></td></tr>
<tr><td><i>Carry him gently to my fairest chamber</i></td></tr>
<tr><td><i>And hang it round with all my wanton pictures:</i></td></tr>
<tr><td><i>Balm his foul head in warm distilled waters</i></td></tr>
<tr><td><i>And burn sweet wood to make the lodging sweet:</i></td></tr>
<tr><td><a href="#50Top" name="50"><u><b>50</b></u></a></td></tr>
<tr><td><i>Procure me music ready when he wakes,</i></td></tr>
<tr><td><i>To make a dulcet and a heavenly sound;</i></td></tr>
<tr><td><i>And if he chance to speak, be ready straight</i></td></tr>
<tr><td><i>And with a low submissive reverence</i></td></tr>
<tr><td><i>Say "What is it your honor will command?"</i></td></tr>
<tr><td>55</td></tr>
<tr><td><i>Let one attend him with a silver basin</i></td></tr>
<tr><td><i>Full of rose-water and bestrew'd with flowers,</i></td></tr>
<tr><td><i>Another bear the ewer, the third a diaper,</i></td></tr>
<tr><td><i>And say "Will't please your lordship cool your hands?"</i></td></tr>
<tr><td><i>Some one be ready with a costly suit</i></td></tr>
<tr><td>60</td></tr>
<tr><td><i>And ask him what apparel he will wear;</i></td></tr>
<tr><td><i>Another tell him of his hounds and horse,</i></td></tr>
<tr><td><i>And that his lady mourns at his disease:</i></td></tr>
<tr><td><i>Persuade him that he hath been lunatic;</i></td></tr>
<tr><td><i>And when he says he is, say that he dreams,</i></td></tr>
<tr><td>65</td></tr>
<tr><td><i>For he is nothing but a mighty lord.</i></td></tr>
<tr><td><i>This do and do it kindly, gentle sirs:</i></td></tr>
<tr><td><i>It will be pastime passing excellent,</i></td></tr>
<tr><td><i>If it be husbanded with modesty.</i></td></tr>
<tr><td><b>FIRST_HUNTSMAN:</b></td></tr>
<tr><td><i>My lord, I warrant you we will play our part,</i></td></tr>
<tr><td>70</td></tr>
<tr><td><i>As he shall think by our true diligence</i></td></tr>
<tr><td><i>He is no less than what we say he is.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Take him up gently and to bed with him;</i></td></tr>
<tr><td><i>And each one to his office when he wakes.</i></td></tr>
<tr><td><b>[Some bear out Sly.]</b></td></tr>
<tr><td><b>[Sound trumpets.]</b></td></tr>
<tr><td><i>Sirrah, go see what trumpet 'tis that sounds:</i></td></tr>
<tr><td><b>[Exit Servingman.]</b></td></tr>
<tr><td><a href="#75Top" name="75"><u><b>75</b></u></a></td></tr>
<tr><td><i>Belike, some noble gentleman that means,</i></td></tr>
<tr><td><i>Travelling some journey, to repose him here.</i></td></tr>
<tr><td><b>[Enter SERVINGMAN.]</b></td></tr>
<tr><td><i>How now! who is it?</i></td></tr>
<tr><td><b>SERVANT:</b></td></tr>
<tr><td><i>An't please your honor, players</i></td></tr>
<tr><td><i>That offer service to your lordship.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Bid them come near.</i></td></tr>
<tr><td><b>[Enter PLAYERS.]</b></td></tr>
<tr><td><i>Now, fellows, you are welcome.</i></td></tr>
<tr><td><b>PLAYERS:</b></td></tr>
<tr><td>80</td></tr>
<tr><td><i>We thank your honor.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Do you intend to stay with me tonight?</i></td></tr>
<tr><td><b>A_PLAYER:</b></td></tr>
<tr><td><i>So please your lordship to accept our duty.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>With all my heart. This fellow I remember,</i></td></tr>
<tr><td><i>Since once he play'd a farmer's eldest son:</i></td></tr>
<tr><td>85</td></tr>
<tr><td><i>'Twas where you woo'd the gentlewoman so well:</i></td></tr>
<tr><td><i>I have forgot your name; but, sure, that part</i></td></tr>
<tr><td><i>Was aptly fitted and naturally perform'd.</i></td></tr>
<tr><td><b>A_PLAYER:</b></td></tr>
<tr><td><i>I think 'twas Soto that your honor means.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>'Tis very true: thou didst it excellent.</i></td></tr>
<tr><td>90</td></tr>
<tr><td><i>Well, you are come to me in a happy time;</i></td></tr>
<tr><td><i>The rather for I have some sport in hand</i></td></tr>
<tr><td><i>Wherein your cunning can assist me much.</i></td></tr>
<tr><td><i>There is a lord will hear you play tonight:</i></td></tr>
<tr><td><i>But I am doubtful of your modesties;</i></td></tr>
<tr><td>95</td></tr>
<tr><td><i>Lest over-eyeing of his odd behavior,-</i></td></tr>
<tr><td><i>For yet his honor never heard a play-</i></td></tr>
<tr><td><i>You break into some merry passion</i></td></tr>
<tr><td><i>And so offend him; for I tell you, sirs,</i></td></tr>
<tr><td><i>If you should smile he grows impatient.</i></td></tr>
<tr><td><b>A_PLAYER:</b></td></tr>
<tr><td><a href="#100Top" name="100"><u><b>100</b></u></a></td></tr>
<tr><td><i>Fear not, my lord: we can contain ourselves,</i></td></tr>
<tr><td><i>Were he the veriest antic in the world.</i></td></tr>
<tr><td><b>LORD:</b></td></tr>
<tr><td><i>Go, sirrah, take them to the buttery,</i></td></tr>
<tr><td><i>And give them friendly welcome every one:</i></td></tr>
<tr><td><i>Let them want nothing that my house affords.</i></td></tr>
<tr><td><b>[Exit one with the Players.]</b></td></tr>
<tr><td>105</td></tr>
<tr><td><i>Sirrah, go you to Barthol'mew my page,</i></td></tr>
<tr><td><i>And see him dress'd in all suits like a lady:</i></td></tr>
<tr><td><i>That done, conduct him to the drunkard's chamber;</i></td></tr>
<tr><td><i>And call him "madam," do him obeisance.</i></td></tr>
<tr><td><i>Tell him from me, as he will win my love,</i></td></tr>
<tr><td>110</td></tr>
<tr><td><i>He bear himself with honorable action,</i></td></tr>
<tr><td><i>Such as he hath observed in noble ladies</i></td></tr>
<tr><td><i>Unto their lords, by them accomplished:</i></td></tr>
<tr><td><i>Such duty to the drunkard let him do</i></td></tr>
<tr><td><i>With soft low tongue and lowly courtesy,</i></td></tr>
<tr><td>115</td></tr>
<tr><td><i>And say "What is't your honor will command,</i></td></tr>
<tr><td><i>Wherein your lady and your humble wife</i></td></tr>
<tr><td><i>May show her duty and make known her love?"</i></td></tr>
<tr><td><i>And then with kind embracements, tempting kisses,</i></td></tr>
<tr><td><i>And with declining head into his bosom,</i></td></tr>
<tr><td>120</td></tr>
<tr><td><i>Bid him shed tears, as being overjoy'd</i></td></tr>
<tr><td><i>To see her noble lord restored to health,</i></td></tr>
<tr><td><i>Who for this seven years hath esteem'd him</i></td></tr>
<tr><td><i>No better than a poor and loathsome beggar:</i></td></tr>
<tr><td><i>And if the boy have not a woman's gift</i></td></tr>
<tr><td><a href="#125Top" name="125"><u><b>125</b></u></a></td></tr>
<tr><td><i>To rain a shower of commanded tears,</i></td></tr>
<tr><td><i>An onion will do well for such a shift,</i></td></tr>
<tr><td><i>Which in a napkin being close convey'd</i></td></tr>
<tr><td><i>Shall in despite enforce a watery eye.</i></td></tr>
<tr><td><i>See this dispatch'd with all the haste thou canst:</i></td></tr>
<tr><td>130</td></tr>
<tr><td><i>Anon I'll give thee more instructions.</i></td></tr>
<tr><td><b>[Exit a Servingman.]</b></td></tr>
<tr><td><i>I know the boy will well usurp the grace,</i></td></tr>
<tr><td><i>Voice, gait and action of a gentlewoman:</i></td></tr>
<tr><td><i>I long to hear him call the drunkard husband,</i></td></tr>
<tr><td><i>And how my men will stay themselves from laughter</i></td></tr>
<tr><td>135</td></tr>
<tr><td><i>When they do homage to this simple peasant.</i></td></tr>
<tr><td><i>I'll in to counsel them; haply my presence</i></td></tr>
<tr><td><i>May well abate the over-merry spleen</i></td></tr>
<tr><td><i>Which otherwise would grow into extremes.</i></td></tr>
<tr><td><b>[Exeunt.]</b></td></tr>
</table>
</body>
</html>
cheers,
tt
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Asst: Using Shell Scripts with sed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: One problem with the use of sed in simple text substitutions is that sed will intepret some characters as... (1 Reply)
Discussion started by: raymondbn
1 Replies

2. UNIX for Dummies Questions & Answers

Rename scripts using xargs/sed

Morning all I've got loads of scripts but the names are too long! I've stuck the list in a flat file (names) and I'm trying to read that in line by line and create the new names (in to directory new) from the list. It looks like this: xargs -n1 -I{} <names cat {} | sed... (1 Reply)
Discussion started by: Grueben
1 Replies

3. UNIX for Dummies Questions & Answers

sed command playing with me!

Hello guys, I was working with my data (a tab delimted text file) in Linux and wanted to replace all "NaN" values in my huge table with "NA", so i used the following sed command: sed 's/NaN/NA/g' /filepath -> outputfile.txt The results were good, all "NaN" were replaced with "NA", but the... (7 Replies)
Discussion started by: Error404
7 Replies

4. Homework & Coursework Questions

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. What i have so far is !/bin/sh File1="$3" File2="$4" File3="$5" testNum="$File1" while test "$testNum" <= "$File3"; do echo... (12 Replies)
Discussion started by: Johnny2518
12 Replies

5. Shell Programming and Scripting

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. I use the program to change an occurance of a word throughout different files that are being tested. At first i had to Create a new script,... (1 Reply)
Discussion started by: Johnny2518
1 Replies

6. UNIX and Linux Applications

Display mysql results nicely

Hi, perhaps this is a dumb question. I'm running queries on mysql and I'm getting tabbed results like these: mysql> SELECT * from metrics_status WHERE date = '2012-03-30'; <TABLE... (1 Reply)
Discussion started by: erick_tuk
1 Replies

7. Shell Programming and Scripting

number sign(#) in sed scripts

Hi. In a simple sed script i have number signs - #. But i can't find any description on their functionality. One thing that i find is that # in sed scripts can mean comment if it is placed in the beginning of the line. I thought may be this undocumented(for me) behavior refers to regular... (1 Reply)
Discussion started by: kukuruku
1 Replies

8. Shell Programming and Scripting

tab string variables nicely

I'm using korn shell for my shell script I'm reading a file and get the data I want out and append it to a variable directly, it shows like this AutoMicroReport_53767.txt BANI BHUM (570N) 20080520 17:54 WAN HAI 306 078 ITH 1 1 HKHKG 20 GP M S06 7 6 1 0 TCYONG AutoMicroReport_53767.txt... (2 Replies)
Discussion started by: finalight
2 Replies

9. UNIX for Dummies Questions & Answers

nicely formatted directory listing from batch ssh session

Hi, I am really struggling to finish of a script I have been assigned. The script's purpose is to log on to each server defined in an array, determine the Web Server version, and list the directory beneath the installation directory. In my case, this installation directory is almost always... (6 Replies)
Discussion started by: grebbux
6 Replies
Login or Register to Ask a Question