[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnu-arch-users] new version hook script examples
From: |
Mark A. Flacy |
Subject: |
Re: [Gnu-arch-users] new version hook script examples |
Date: |
14 Nov 2004 10:48:59 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
>>>>> "Zenaan" == Zenaan Harkness <address@hidden> writes:
Zenaan>
Zenaan> On Sun, 2004-09-26 at 10:33, Zenaan Harkness wrote:
Zenaan>
Zenaan> BTW, does anyone know/ use an alternative to perl -i for in-place
Zenaan> munging? I guess I should learn how to chain multiple lines such as the
Zenaan> following into one, since firing up perl for each line seems rather
Zenaan> heavy weight.
Well, use ed. Read the file in, do your search and replace, and write the
file out.
An example would be this slightly modified repackage script that I wrote...
#! /bin/bash
TMP=${TMPDIR:-/tmp}/munge.sh.$$
trap "rm $TMP* 2>/dev/null" 0
#
# All of FROML is passed to grep to find any matches
# Treat FROML and TOL as two matching lists; the first item in
# FROML will be replaced with the first item in TOL and so on.
#
# The lists are processed in reverse order.
#
#
# Amazing what you can do with this stuff
#
# normally called as....
# find . -type d | xargs -n1 munge.sh
#
# And yes, the find loop could be inside the script.
FROML=(
"com\.xxx\.ims\.foundation\.lang\.Class1"
"com\.xxx\.ims\.foundation\.lang\.Class2"
"com\.xxx\.ims\.foundation\.lang\.Class3"
)
TOL=(
"com\.xxx\.ims\.foundation\.runtime\.Class1"
"com\.xxx\.ims\.foundation\.system\.Class2"
"com\.xxx\.ims\.foundation\.netfx\.Class3"
)
EDSCR=$TMP.edscr
echo "f" > $EDSCR
for ((lim=${#FROML[*]} ; lim ; lim--)); do
echo "g@"${FROML[lim-1]}"@s@"${FROML[lim-1]}"@"${TOL[lim-1]}"@g" >> $EDSCR
done
echo "wq" >> $EDSCR
#echo "--------------"
#cat $EDSCR
#echo "--------------"
#echo
echo " " >> $EDSCR
for i in "$1"/*; do
if [ -f "$i" ]; then
grep -q -f $TMP "$i" && (
echo "Matches in $i"
chmod +w $i
ed $i <$EDSCR
echo "$i complete"
)
fi
done
Zenaan>
Zenaan> perl -pi -e "s#SUB_WEB_HOST#$SUB_WEB_HOST#g;" $SED_FILES
Zenaan> perl -pi -e "s#SUB_server.host#$SUB_server_host#g;" $SED_FILES
Zenaan> ...
Zenaan>
Zenaan> ??
Zenaan>
Zenaan> tia
Zenaan> zen
Zenaan>
Zenaan>
Zenaan> _______________________________________________
Zenaan> Gnu-arch-users mailing list
Zenaan> address@hidden
Zenaan> http://lists.gnu.org/mailman/listinfo/gnu-arch-users
Zenaan>
Zenaan> GNU arch home page:
Zenaan> http://savannah.gnu.org/projects/gnu-arch/
Zenaan>
--
Mark A. Flacy
Any opinions expressed above are my own. Any facts expressed above
are, ummm, facts.