Welcome > Linux > Miscellaneous > Script Changes to a System

Script Changes to a System

# cp oldfile changedfile
# vi changedfile
--- edit file ---
# diff -e oldfile changedfile > edscr 
# echo w >> edscr 
--- move edscr to target system ---
# ed oldfile < edscr 
# diff oldfile changedfile


I've used the above technique when scripting changes to a file. I make the desired change, run the "diff -e", then build a here document. For example:

cd /etc
cp -p logrotate.conf logrotate.conf.orig
ed logrotate.conf <<EOF 21c
    rotate 8
# keep 8 weeks worth of backlogs
rotate 8

Remember, I edited the logrotate.conf file first to get the diff. This technique allows me to script a build, or make modifications to large numbers of servers with a simple script.

Content Copyright 2003-2014 George Toft