Christiansource Archive

List Statistics

  • Total Threads: 420
  • Total Posts: 976

Phrases Used to Find This Thread

  #1  
08-06-2011 02:58 PM
Christiansource member admin is online now
User
 

My web site has gotten badly out dated from lack of maintainence. I want
to get it back in shape. One of the most immediate problems is that
(since we added a blog, and gave it the address that was the address of
the whole web site) every "home button" in every html file instead of
leading back to the old "home page", leads back to the blog.

I need a way to edit all of those html files with a "find and replace"
function to correct that (and other errors). I'm using Mint10 (nearly the
same as ubuntu).

I'd prefer a color coded html editor capable of multiple documents, but
even an effective method to do it from command line (if I can find
adequate and simple documentation) would do the job.

Any suggestions?

Dave



_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #2  
08-06-2011 03:04 PM
Christiansource member admin is online now
User
 

On 06/08/2011 09:58 AM, wrote:
> My web site has gotten badly out dated from lack of maintainence. I want
> to get it back in shape. One of the most immediate problems is that
> (since we added a blog, and gave it the address that was the address of
> the whole web site) every "home button" in every html file instead of
> leading back to the old "home page", leads back to the blog.
>
> I need a way to edit all of those html files with a "find and replace"
> function to correct that (and other errors). I'm using Mint10 (nearly the
> same as ubuntu).
>
> I'd prefer a color coded html editor capable of multiple documents, but
> even an effective method to do it from command line (if I can find
> adequate and simple documentation) would do the job.
>
> Any suggestions?
>
> Dave
>
>
>
> _______________________________________________
> ChristianSource FSLUG mailing list
>
> http://cs.uninetsolutions.com

for file in *.html; do sed -i 's/blogpage/homepage/g' $file; done
--
-Linc Fessenden

In the Beginning there was nothing, which exploded - Yeah right...

_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #3  
08-06-2011 03:06 PM
Christiansource member admin is online now
User
 

On Wed, 8 Jun 2011, wrote:

> I need a way to edit all of those html files with a "find and replace"
> function to correct that (and other errors). I'm using Mint10 (nearly the
> same as ubuntu).
>
> I'd prefer a color coded html editor capable of multiple documents, but
> even an effective method to do it from command line (if I can find
> adequate and simple documentation) would do the job.

I'm sure someone here can help you construct a sed command for that. But
to answer the tangential question of editing by hand, I highly recommend
Cream. I'm sure it's available from the standard Ubuntu/Mint
repositories. It will take a few moments to learn, but this tame
interface on top of Gvim offers the most extravagant syntax coloring
I've ever seen. I prefer the setting which turns the color scheme into
"terminal (reverse)" white-on-black, but there are numerous themes out
there. Of course, if you know a little about Vim already, then Gvim is
even better.

Ed Hurst
--------
Open for Business - http://ofb.biz/
Kiln of the Soul - http://soulkiln.org/
blog - http://soulkiln.myopera.com/

_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #4  
08-06-2011 03:24 PM
Christiansource member admin is online now
User
 



On 6/8/2011 9:04 AM, l4c wrote:
> On 06/08/2011 09:58 AM, wrote:
>> My web site has gotten badly out dated from lack of maintainence.
>> I want
>> to get it back in shape. One of the most immediate problems is that
>> (since we added a blog, and gave it the address that was the
>> address of
>> the whole web site) every "home button" in every html file instead of
>> leading back to the old "home page", leads back to the blog.
> for file in *.html; do sed -i 's/blogpage/homepage/g' $file; done

I would like to second this, but add a little more information. If
you are not experienced in sed, this may give you some issues without
more knowledge.

Sed is a pattern matching/replacing program. Basically, the "sed -i"
command does an in-place change of the files. It reads the file,
makes a change, and writes back to the original file.

The "*for file in *.html;*" portion will find all the html files in
the current directory, and then do the sed edit on each one
individually. If you have multiple subdirectories, you will either
need to run this command on all of the subdirectories or use "find"
or something similar to do it for all of them.

The sed command itself, while fairly straight-forward, can give you
grief if you have any path-parts to your link. For example, if you
were trying to match "/Dave/blog" and replace it with
"/newpage/index.html" you will run into some issues. The "/"
character is the magical separator, and needs to be prefixed with a
back-slash. So you would need to have the sed command be:
's*/*\/Dave\/blog*/*\/newpage\/index.html*/'
*I am hoping that the bolded slashes show off. The bolded slashes
are the slashes that have not been escaped, and are the separators.
They designate the two sections, a "match this" section, and a
"replace it with this" section.

One problem with the sed -i solution is that it is permanent,
regardless of what you intended. There is no "undo" button. You
will want to make a backup of your files before you do it.

But, when you are simply doing a one-to-one replacement, it is a very
simple and effective thing to do. If you are struggling with this,
drop us an email with the text of the actual href you would like to
replace, and what you would like to change it to.

- Tim

_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #5  
08-06-2011 03:36 PM
Christiansource member admin is online now
User
 

On Wed, 8 Jun 2011 08:58:04 -0500
wrote:

> I'd prefer a color coded html editor capable of multiple documents,
> but even an effective method to do it from command line (if I can find
> adequate and simple documentation) would do the job.
>
> Any suggestions?

Hi Dave,

I used LMDE for a bit, but realized I wasn't using most of the 'minty'
add-ons, so now I'm using Debian testing (xfce) and it's great.

So to answer your question, on gnome I was used to gedit which will do
color coding of html or other types of text and will do multiple
documents in tabs. As I'm now using xfce I decided to try Geany and
it's really good. I would use it over gedit on gnome, even. If I open
an html file it'll code the different tags a different color, and you
can probably edit the colors it uses, but so far I haven't needed to
find that option. I haven't done any major revision of articles on my
site lately, either...

Another possibility that I've seen suggested by others, but I've not
played with it very much is bluefish (editor), the package name in
synaptic is just bluefish. Here's the description:

"Bluefish is a GTK+ HTML editor for the experienced web designer.
Its features include nice wizards for startup, tables and frames; a
fully featured image insert dialog; thumbnail creation and automatically
linking of the thumbnail with the original image; and configurable HTML
syntax highlighting.

For validation to work you need weblint and xmllint. For preview to
work, you need a web browser that can view local files given to it
on the command line."

Most likely geany will do the trick .

Cia

_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #6  
09-06-2011 08:58 PM
Christiansource member admin is online now
User
 

First: Thank you all for trying to help me with this. I got to
exploring Gedit, and was really surprised at what it can do. I had
thought that it was just a simple text editor. It can certainly make
life easier.

But that command line with sed looks as if it ought to be the quickest
way. Here's what I did: I downloaded my website to my hard drive. Then
I sorted through it and put all of the htm or html files in a separate
directory.

here are the changes that need to be made:

old line:

Return to Home
page.



new line:

Return to Home
page.



second change:
old line:
(Harvesting
Harvesters
)



(Harvesting
Harvesters
)



In both cases it appears to me that all that needs to be changed is
"index.php" to "index2.htm" Near as I can tell that change in any place
on any of my html files shouldn't make any negative difference. In fact
I'm quite certain that it needs to be changed wherever it occurs.

went to a terminal and changed directory to the directory where those
*.htm? files are, and inserted this line after the "$" prompt.

I tried to do just a small subset (those *.html files that begin with
the letter "g") Here's what I tried: (didn't get any errors, but also it
didn't make the expected changes)

for file in g*.htm?; do sed -i 's/index.php/index2.htm/g' $file; done

I also tried it with the descrption of the files to change as being
just *.htm and also *.html

I didn't try it as root - didn't know if it was safe to do so. What am
I missing? Or how have I messed up the command?

Dave







_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #7  
09-06-2011 09:31 PM
Christiansource member admin is online now
User
 

On Thu, Jun 9, 2011 at 2:58 PM, <> wrote:

> for file in g*.htm?; do sed -i 's/index.php/index2.htm/g' $file; done
>


> I didn't try it as root - didn't know if it was safe to do so. What am I
> missing? Or how have I messed up the command?
>

Some things that I would try...
1. Does "ls g*.htm?" display a file list? This will tell you if the problem
is in the glob or the sed command.
2. In the sed expression, escape the period: s/index\.php/index2.htm/g.
Theoretically, the period matches any character. The original, un-escaped
pattern matches "index-php" or "indexAphp". In practice, it probably doesn't
matter and I'm just being paranoid.
3. Put quotation marks around $file: sed -i 's/index.php/index2.htm/g'
"$file". This protects files that might have spaces in their name.

--
Robert Wohlfarth



  #8  
10-06-2011 01:25 AM
Christiansource member admin is online now
User
 

"ls g*.htm?" does display a file list, but only of those files htm
files that end with an "l", so I guess that "?" means any letter that is
there, but insists that there be some letter there. escaping the period
didn't help, but that may be because I made too many changes before I
tried it.

Finaly: when I tried:"for file in i*.htm; do sed -i
's/index.html/index2.htm/g' $file; done" It worked for all the files
that started with "i" and ended with ".htm" Then: "for file in *.htm;
do sed -i 's/index.html/index2.htm/g' $file; done" Got the rest of them.
except for the ones that end with "l", or something completely
different.

Thanks this looks like an excellent tool if I can just learn how to use
it effectively.

Dave

On Thu, 9 Jun 2011 15:31:02 -0500, Robert Wohlfarth wrote:
> On Thu, Jun 9, 2011 at 2:58 PM, wrote:
>
>> for file in g*.htm?; do sed -i 's/index.php/index2.htm/g' $file;
>> done
>
>  
>
>> I didn't try it as root - didn't know if it was safe to do so.
>>  What am I missing? Or how have I messed up the command?
>
> Some things that I would try...
> 1. Does "ls g*.htm?" display a file list? This will tell you if the
> problem is in the glob or the sed command.
> 2. In the sed expression, escape the
> period: s/index.php/index2.htm/g. Theoretically, the period matches
> any character. The original, un-escaped pattern matches "index-php"
> or
> "indexAphp". In practice, it probably doesn't matter and I'm just
> being paranoid.
> 3. Put quotation marks around $file: sed -i
> 's/index.php/index2.htm/g' "$file". This protects files that might
> have spaces in their name.


_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com

  #9  
10-06-2011 01:41 AM
Christiansource member admin is online now
User
 

Sed is one of those "amazing" unix tools. I have been using it for
years and years (15+) and still do not think I am effective with it.
:) There are tons of things that I once knew how to do with it that
I no longer can... But I can still do a lot more with it than a lot
of people can. :) It is the equivalent of a blow-torch or a
chainsaw. Some people do a lot more with it than others...

(If I remember the story correctly, Dave, to whom I am talking, once
kept an engine from falling out of a truck by using a chain-saw
creatively. Putting "sed" into his hands may be interesting...
Looking forward to seeing what he does with it.)

- Tim

On 6/9/2011 7:25 PM, wrote:
> "ls g*.htm?" does display a file list, but only of those files htm
> files that end with an "l", so I guess that "?" means any letter
> that is there, but insists that there be some letter there.
> escaping the period didn't help, but that may be because I made too
> many changes before I tried it.
>
> Finaly: when I tried:"for file in i*.htm; do sed -i
> 's/index.html/index2.htm/g' $file; done" It worked for all the
> files that started with "i" and ended with ".htm" Then: "for
> file in *.htm; do sed -i 's/index.html/index2.htm/g' $file; done"
> Got the rest of them. except for the ones that end with "l", or
> something completely different.
>
> Thanks this looks like an excellent tool if I can just learn how to
> use it effectively.
>
> Dave
>
>

_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)

  #10  
10-06-2011 05:09 AM
Christiansource member admin is online now
User
 

I don't remember that story, Tim, unless the "truck" was really a Renault
car, and the chainsaw was some willing helpers with machetes. Now *that
story* (along with several more) can be found here:
http://hisfeet.net/dindex.htm/ebook_b.exe (That was in the days before I
knew anything about Linux). Guess I'll need to bust it out of that exe
file so others can reach it conveniently (someday :)

By the way, the gospel deprived village where that took place now has a
thriving community of believers.

davem


> Sed is one of those "amazing" unix tools. I have been using it for
> years and years (15+) and still do not think I am effective with it.
> :) There are tons of things that I once knew how to do with it that
> I no longer can... But I can still do a lot more with it than a lot
> of people can. :) It is the equivalent of a blow-torch or a
> chainsaw. Some people do a lot more with it than others...
>
> (If I remember the story correctly, Dave, to whom I am talking, once
> kept an engine from falling out of a truck by using a chain-saw
> creatively. Putting "sed" into his hands may be interesting...
> Looking forward to seeing what he does with it.)
>
> - Tim
>
> On 6/9/2011 7:25 PM, wrote:
>> "ls g*.htm?" does display a file list, but only of those files htm
>> files that end with an "l", so I guess that "?" means any letter
>> that is there, but insists that there be some letter there.
>> escaping the period didn't help, but that may be because I made too
>> many changes before I tried it.
>>
>> Finaly: when I tried:"for file in i*.htm; do sed -i
>> 's/index.html/index2.htm/g' $file; done" It worked for all the
>> files that started with "i" and ended with ".htm" Then: "for
>> file in *.htm; do sed -i 's/index.html/index2.htm/g' $file; done"
>> Got the rest of them. except for the ones that end with "l", or
>> something completely different.
>>
>> Thanks this looks like an excellent tool if I can just learn how to
>> use it effectively.
>>
>> Dave
>>
>>
>
> _______________________________________________
> ChristianSource FSLUG mailing list
>
> http://cs.uninetsolutions.com
>



_______________________________________________
ChristianSource FSLUG mailing list

http://cs.uninetsolutions.com
)





NewsArc Lists  |  Culture Pages   |  Computing Archive  |  Media-Pages
Link to this page on your blog or website by copying the HTML code below and pasting it into your site: