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