in reply to perl code to replace

If you happen to be in a bash shell, then you hardly need to invoke Perl, since you have builtins at your disposal..
for N in *.xml; do mv $N ${N/%xml/txt} done
but if you must do that in Perl you can
perl -e 'qx!for N in *.xml\; do mv \$N \${N/%xml/txt}\; done!;'
:)

Note, though, TMTOWTDI: site:perlmonks.org rename files directory


Also this: Re: What one-liners do people actually use? is awesome.

correction: /%xml/ not /xml/ good catch suhailck!

Replies are listed 'Best First'.
Re^2: perl code to replace
by suhailck (Friar) on Feb 10, 2011 at 17:24 UTC
    Your bash script replaces filename like "xml.xml" to "txt.xml". I think you need to change the script as follows inorder to work as expected,

    mv $N ${N/%xml/txt}