Register
It is currently Sat Oct 25, 2014 8:58 pm

help with adding same text to 300 files


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Jan 26, 2007 3:51 am   

Joined: Tue Jan 23, 2007 6:44 am
Posts: 1
Location: ZA
I have installed bind9 on a *BSD and copied zone file from suse* bind8 as well. my problem I have to add a line like "$TTL 1d" to the top of every zone file I have about 400 in all. I tried vi but editing all these files by hand to add a single line proved cumbersome. all files in 1 DIR /var/named/ domain1.com domain2.com donaim3.com etc. Can anyone help witth a script to update all these files to add the text.


Top
 Profile YIM  
 PostPosted: Fri Jan 26, 2007 12:50 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
i would personally run a loop
something like:
Code:
for i in *
do
    echo '$TTL 1d' > tmp
    cat "$i" >> tmp
    mv tmp "$i"
done

this ofcourse assumes that you are in the directory where you want to make changes, and that ALL files in that directory should get the change.

if it's not all files that should get the change, alter the for line
example: you want to exit only files that end with .com
Code:
for i in *.com
do
    echo '$TTL 1d' > tmp
    cat "$i" >> tmp
    mv tmp "$i"
done


hope that helps :)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP