update - Greple module to update files
greple -Mupdate
Options:
--update --with-backup --diff --diffcmd command
Version 0.01
This greple module substitute the target file contents by command output. For example, next command replace all words in the file to uppercase.
greple -Mupdate '\w+' --cm 'sub{uc}' --update file
Above is a very simple example but you can implement arbitrarily complex convert function in conjunction with other various greple options.
You can check how the file will be edited by --diff option.
greple -Mupdate '\w+' --cm 'sub{uc}' --diff file
Command sdif or cdif is should be useful to see the difference visually.
greple -Mupdate '\w+' --cm 'sub{uc}' --diff file | cdif
This module has spun off from App::Greple::subst module. Consult it for more practical use case.
Update the target file by command output. Without this option, greple behaves as normal operation, that means only matched lines are printed.
Backup original file with ".bak" suffix. If optional parameter is given, it is used as a suffix string.
Option -diff produce diff output of original and converted text.
$ cpanm App::Greple::update
$ cpanm https://github.com/kaz-utashiro/greple-update.git
https://github.com/kaz-utashiro/greple-update
https://github.com/kaz-utashiro/greple
https://github.com/kaz-utashiro/greple-subst
Kazumasa Utashiro
Copyright 2022 Kazumasa Utashiro.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install App::Greple::update, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Greple::update
CPAN shell
perl -MCPAN -e shell install App::Greple::update
For more information on module installation, please visit the detailed CPAN module installation guide.