#!/bin/bash # Utility to rename Java package names from org.objectweb to org.ow2 in text files # Special focus on CLIF project by especially taking care of *.classname and *.ctp files process() { tmpfile="$1-tmp$$" sed 's/org.objectweb/org.ow2/g' "$1" > "$tmpfile" mv "$tmpfile" "$1" } usage() { exec="`basename $0`" printf "Utility for renaming Java package names from org.objectweb to org.ow2 in text files.\n" printf "usage:\n" printf "\t$exec\n" printf "\t\trecursively finds and processes all .classname and .ctp files from current directory.\n" printf "\t$exec [directory or file name]...\n" printf "\t\tprocesses a list of files, and recursively finds and processes all .classname and .ctp files from a list of directories.\n" } if test "$1" = "-h" then usage exit fi if test $# -eq 0 then PATHS=. else PATHS=$@ fi for p in $PATHS do if test -d "$p" then find "$p" \( -name \*.classname -o -name \*.ctp \) -print | while read filename do process "$filename" done else process "$p" fi done