If you want to edit a bunch of files – for dns updates on bind for example, do this:

sed –i s/<text to replace>/<text to replace with>/g filename_to_change

If you’re concerned about backups, then you can do this:

sed –i’<orginal backup file extension>’ s/<text to replace>/<replacement text>/g filename_to_change

e.g. if we want to edit a file and keep the original with a .old extension the following would work

sed –i’.old’ s/<text to replace>/<replacement text>/g filename_to_change

Notice the single quotes after the ‘i’. This will produce a file with an extension of .old as a backup.

Tags: , , , , , ,

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>