TheTAZZone - Internet Chaos

Editing multiple files with one script

ORIGINALLY POSTED BY OPUS FOR THETAZZONE/TAZFORUM HERE

Do not use, republish, in whole or in part, without the consent of the Author. TheTAZZone policy is that Authors retain the rights to the work they submit and/or post…we do not sell, publish, transmit, or have the right to give permission for such…TheTAZZone merely retains the right to use, retain, and publish submitted work within it’s Network

I wrote some code a few years back, basically it was channel services for IRC. It has about 96 .c files that are compiled into a single binary. Each file contains copyright info at the top, so rather than edit each file one at a time to modify the copyright each year, I wrote a script to do it for me.

Code:
#!/bin/sh
for x in *.c
do
echo $x
ed -s $x << end
g/some string/s//to some other string/g
w
q
end
done

Of course you can modify it to suit your need to edit other type files. The key being each file contains “some string”

Leave a Reply

Your email address will not be published. Required fields are marked *

Advertise

If you'd like to advertise on The Mutt ( aka TheTAZZone.com ) feel free to contact us at: administration[at]thetazzone.com

TheTAZZone is a non-commercial entity. We do not sell any products or services ourselves. Our revenue comes from advertising and donations only.

We appreciate your support! Your advertising revenue ( or donations ) helps us to continue to upgrade, improve, and offset the costs of maintaining this site.

Donations can be made through the page ' Donate '.