Simple instructions how to generate a script from diff to restore changes,
which were found by diff.
-
Sometimes it is required to run a script to apply changes to a file, which
were found by the unix diff utility. The diff has to be run with the
following command, and then ed is used to run the script.:
#create an example for demo:
date > date_1
date > date_2
diff --ed date_1 date_2 > command.txt
ed -s date_1 < command.txt
Note that you have to add w in the last line of
the script, to write the changes.
-
Now run again the unix diff utility and
see that files are the same with the content of
date_2.
-
I used it for a regression script. The script,
randomly generates a configuration.ini file. I
keep only the changes from a base one, to save
disk space. In the following example _reg is the
base and .ini is the one used for regression.
- $cmd="diff --ed configuration.ini configuration_reg.ini > logs/R" . $pl_seed;
- chomp($cmd);
- $cmd=$cmd . "_config_com.txt";
- system($cmd);
To restore the configuration.ini of the test, see the next example:
cp configuration_reg.ini configuration.ini
ed -s configuration.ini < R1368081915_config_com.txt
|