[CS-FSLUG] I need a q'n'd shell script or something for batch file editing

Timothy R. Butler tbutler at uninetsolutions.com
Sat Oct 16 22:32:08 CDT 2004


Hi everyone,

PROBLEM: Internet Explorer chokes on a line of code that works great in 
-- apparently -- every other browser ever on the face of the earth.

FIX: Switch the call for a stylesheet from using a relative path to an 
absolute path.

NEW PROBLEM: That change needs to be made in a very large number of 
files on my client's site.

What I need is to find a way to write a quick and dirty batch script 
that will edit the right line in each file.

Grep can find the line just fine. Here's a bit of its output:

--------
tbutler at cedar [/home/mary/www]# grep css *
account_edit.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account_history_info.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account_history.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account_newsletters.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account_notifications.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account_password.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
account.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
address_book.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
address_book_process.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
advanced_search.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
advanced_search_result.php:<link rel="stylesheet" type="text/css" 
href="stylesheet.css">
[...it goes on and on and on...]
---------

Any suggestions on how I might edit each of these lines with as little 
effort as possible. I guess, come to think of it, maybe I could whip 
something up in Perl, but it seems like there should be an even easier 
shell based solution...

ideas?

	Thanks,
		Tim


---------------------------------------------------------------
Timothy R. Butler       Universal Networks      www.uninet.info
==================== <tbutler at uninet.info> ====================
| Christian Portal:      | Have you not learned great lessons |
|      www.faithtree.com | from those  who  braced themselves |
| GNU/Linux News:        | against  you   and   disputed  the |
|            www.ofb.biz | passage with you?   --Walt Whitman |
---------------------------------------------------------------
Presently on "Albert" (DP PPC 970 "G5" running at 2.0 GHz)





More information about the Christiansource mailing list