To perform search-and-replace operations with extended regular expressions, copy
and paste the following script to /usr/local/bin/extreg or $HOME/bin/extreg:
"regexp" are one ore more extended regular expressions, separated by semicolon.
"separator" is an optional separator,see perlvar(1), section $INPUT_RECORD_SEPARATOR. The data which has to be processed is divided into (with the separator ending) blocks, on which the regular expressions are applied.
If you want to be portable you should invoke perl directly. "extreg" is primarily meant to be used in your private scripts or in interactive shell mode.
and paste the following script to /usr/local/bin/extreg or $HOME/bin/extreg:
#!/bin/sh
if [ $# -gt 1 ]; then
perl -we '$/="'"$2"'";while(<>){'"$1"';print $_}'
else
perl -we 'undef $/;$_=<>;'"$1"';print $_;'
fi
Syntax: extreg regexp [separator]if [ $# -gt 1 ]; then
perl -we '$/="'"$2"'";while(<>){'"$1"';print $_}'
else
perl -we 'undef $/;$_=<>;'"$1"';print $_;'
fi
"regexp" are one ore more extended regular expressions, separated by semicolon.
"separator" is an optional separator,see perlvar(1), section $INPUT_RECORD_SEPARATOR. The data which has to be processed is divided into (with the separator ending) blocks, on which the regular expressions are applied.
If you want to be portable you should invoke perl directly. "extreg" is primarily meant to be used in your private scripts or in interactive shell mode.
0 blogger-disqus:
Post a Comment