rename.sh 749 Bytes
Newer Older
Pavel Sharov's avatar
Pavel Sharov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#! /bin/bash
# Replace Go4 demo analysis by user experiment names
# J.Adamczewski 18.03.2002
# H.Essel 30.7.2002: two args
# The GSI Online Offline Object Oriented (GO4) Project
# Experiment Data Processing at DVEE department, GSI
# usage: rename.sh old new
FILELIST='Makefile Module.mk *.cxx *.h *.C Readme.txt'
#echo $FILELIST
if [ $# -ne 2 ] ; then
echo 'args: "oldstring" "newstring"'
else
echo Replace $1 by $2 in
echo "Makefile Module.mk *.cxx *.cpp *.h Readme.txt"
for FILENAME in $FILELIST;
do
#echo $FILENAME;
cat  $FILENAME | awk -v rep=$2 -v str=$1 '{ gsub(str,rep) ; print }' > temp.txt
mv temp.txt $FILENAME;
NEWNAME=`echo $FILENAME | awk -v rep=$2 -v str=$1 '{ gsub(str,rep) ; print }'`;
echo $NEWNAME;
mv $FILENAME $NEWNAME;
done
fi