config-patch - Apply modifications to config files and take them back


NAME

    config-patch - Apply modifications to config files and take them back


SYNOPSIS

        # Append a patch
    echo "my patch text" | config-patch -a -k key -f config_file
        # Prepend a patch
    echo "my patch text" | config-patch -p -k key -f config_file
        # Remove a patch
    config-patch -r -k key -f config_file
        # Patch a section matched by a regex
    echo "replace" | config-patch -s 'regex' -k key -f config_file
        # Comment out a section matched by a regex
    config-patch -c 'regex' -k key -f config_file


OPTIONS

-a

Appends text to the configuration file. The text can be provided either via STDIN or by specifying a file name:

            # Append a patch
    echo "my appended text" | config-patch -a -k key -f config_file
            # Append a patch
    config-patch -a -k key -f config_file appended_text.txt
-p

Adds text to the beginning of a configuration file. The text can be provided either via STDIN or by specifying a file name:

            # Prepend a patch
    echo "my prepend text" | config-patch -p -k key -f config_file
            # Prepend a patch
    config-patch -p -k key -f config_file prepended_text.txt
-r

Removes the patch specified by the key (see -k).

-f filename

Specifies the config file to apply/remove the patch on/from.

-k key

Specifies the key of the patch.

-l

Flock the file exclusively before performing updates.

-h

Prints this manual page in text format.

-s

Apply a patch by using search-and-replace. The search term is a regular expression, the replacement string

    echo "none:" | config-patch -s 'all:.*' -k key -f config_file
-i

insert a patch by using insert. The search term is a regular expression. By default, the "text to insert" is inserted onto the line above the regex. By utilising the -A flag, then the text will be inserted on the line below the regex.

    echo "text to insert" | config-patch -i 'text to find' -k key -f config_file
-A

used with the -i flag. this will insert the text on the line below the regex.

-c

Comment out a section in a configuration file matched by a regular expression. Example:

    config-patch -c 'all:.*' -k key -f config_file
-v

Prints the current version of config-patch.

-C

Use a different comment character than '#'. Example:

    config-patch -C ";" -a -k key -f config_file appended_text.txt


DESCRIPTION

config-patch performs modifications on configuration files and removes them later. It keeps track of modifications by assigning a key to each of them and by storing this key in a comment around the applied patch.

Then, when asked later to remove the patch, it will track it down the patched section(s) by key and remove them.


LEGALESE

Copyright 2005 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


AUTHOR

2005, Mike Schilli <cpan@perlmeister.com>