[Gllug] error in bash script to rename files in a directory

Tethys tet at accucard.com
Tue Dec 31 10:17:07 UTC 2002

Stig Brautaset writes:

>> $ perl -p -i.bak -e 's/php3/php/g' *
>Or without perl:
>for i in *; ex $i <<EOF

True, but ex is designed as an interactive editor, and while you *can*
kludge it to run non-interactively like this, why not just use sed,
which was desgined from the start for non-interactive use?

	for i in *
		sed 's/php3/php/g' "$i" > "$i.$$"
		[ -s "$i.$$" ] && mv "$i.$$" "$i"


Gllug mailing list  -  Gllug at linux.co.uk

More information about the GLLUG mailing list