Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

Simple instructions how to generate a script from diff to restore changes, which were found by diff.

  1. 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.

  2. Now run again the unix diff utility and see that files are the same with the content of date_2.


  3. 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.

    1. $cmd="diff --ed configuration.ini configuration_reg.ini > logs/R" . $pl_seed;
    2. chomp($cmd);
    3. $cmd=$cmd . "_config_com.txt";
    4. 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

 



Home

Send mail with Kmail & DCOP

Download Area






Search This Site




new pages on this site