Sponsored Content
Top Forums Shell Programming and Scripting sed scripts are not playing nicely! Post 302433412 by naphelge on Tuesday 29th of June 2010 01:55:43 PM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
All times are GMT -4. The time now is 08:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy