<div class="gmail_quote">On Thu, Jun 9, 2011 at 2:58 PM,  <span dir="ltr"><<a href="mailto:davidm@hisfeet.net">davidm@hisfeet.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
for file in g*.htm?; do sed -i 's/index.php/index2.htm/g' $file; done<br></blockquote><div><snip> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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?<br></blockquote></div><br clear="all">Some things that I would try...<div>1. Does "ls g*.htm?" display a file list? This will tell you if the problem is in the glob or the sed command.</div>
<div>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.</div>
<div>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.<br><div><br>-- <br>Robert Wohlfarth<br><br>
</div></div>