[CS-FSLUG] I need a quick way to edit quite a few html documents

davidm at hisfeet.net davidm at hisfeet.net
Fri Jun 10 11:26:48 CDT 2011


Thanks you are quite right. I've got the whole thing on my computer now,
so now is a good time to make adjustments like that.


> Just a foot note, but if I were you, I'd get all your htm and html
> files on the same extension for sanity sake next time you have to do
> this. You can use the same sorts of tricks to make all the links
> inside the files go to html and then rename the files themselves to be
> html.
>
> JSR/
>
> On Thu, Jun 9, 2011 at 8:25 PM,  <davidm at hisfeet.net> 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
>>
>> 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
>> Christiansource at ofb.biz
>> http://cs.uninetsolutions.com
>
> _______________________________________________
> ChristianSource FSLUG mailing list
> Christiansource at ofb.biz
> http://cs.uninetsolutions.com






More information about the Christiansource mailing list