Sunday, October 12, 2014

Perl RegEx: Updating files


Using the Perl Interpreter to update a single file

perl -p -i -e 's{^([^\b\w\t]*)(.*)(openApplication)([^>]*)(.*) Form Menu(.*)$}{\1\2\3\4}' $APACHE_DOCS/$APP_URI/index.html


Using xargs to pass command line parameters to perl

cd /usr/local/adobe/central/

egrep -ir csr00001 * | cut -d: -f1 | xargs perl -p -i -e 's/csr00001/$ENV{HOSTNAME##.*}/g'

No comments: