config-patch - Apply modifications to config files and take them back
# 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
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
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
Removes the patch specified by the key (see -k).
Specifies the config file to apply/remove the patch on/from.
Specifies the key of the patch.
Flock the file exclusively before performing updates.
Prints this manual page in text format.
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
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
used with the -i flag. this will insert the text on the line below the regex.
Comment out a section in a configuration file matched by a regular expression. Example:
config-patch -c 'all:.*' -k key -f config_file
Prints the current version of config-patch.
Use a different comment character than '#'. Example:
config-patch -C ";" -a -k key -f config_file appended_text.txt
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.
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.
2005, Mike Schilli <cpan@perlmeister.com>