ths-scripts/applysed

60 lines
1.7 KiB
Plaintext
Raw Normal View History

2009-02-09 21:47:24 +00:00
#!/bin/bash
#
# Copyright 2007, Donatas Glodenis <dgvirtual@akl.lt>
#
# #
# # This script is free software; you can redistribute it and/or modify
# # it under the terms of the GNU General Public License 2 as published by
# # the Free Software Foundation.
#
# # This script is distributed in the hope that it will be useful,
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# # GNU General Public License for more details.
# #
# # You should have received a copy of the GNU General Public License
# # along with this script; if not, write to the Free Software
# # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ths-applysed.sh - apply a sed script to the whole project (the sed commands
# have to be supplied in an external file).
2009-02-09 21:47:24 +00:00
## example of the replacements file content (remove preceeding comment marks #
## and the ======== lines ):
2009-02-09 21:47:24 +00:00
# ==================
# s/bylai/failui/g
# s/bylą/failą/g
# s/byloje/faile/g
# ==================
function usage() {
echo "Usage: `basename $0` <FULL-PATH-TO-file-with-replacement-list> <FULL-PATH-TO-base-directory>"
echo "WARNING: "
echo "SPECIFY FULL PATHS, OTHERWISE ALL YOUR FILES WILL BE DELETED!"
echo "DO A BACKUP BEFORE USING THIS SCRIPT!"
echo
echo "Example of the replacements file content"
echo "======== file begins ========"
echo "s/bylai/failui/g"
echo "s/bylą/failą/g"
echo "s/byloje/faile/g"
echo "======== file ends =========="
exit 1
}
if [ $# -ne 2 ]; then
usage
fi
replacefile=$1
directory=$2
cd $directory
for po in `find . -name "*.po" | sort`
do
echo "Working on $po ..."
sed --file=$replacefile -i $po
echo "...done."
done