perl hack

somebody here asked me just now. i have a list of files. i want to move them to filename.old. What is the simplest one liner?

i suggested this.


$ head a.txt
Tools.tex
anbe_sivam.tex
appendix.tex
bg.tex
cc-upgrade.tex
chandru_bank.tex
demo1.tex
ding.tex
eso-ex2.tex
ex4.tex

$ perl -pi -e 's/(.*)/mv \1 \1\.old/' a.txt

$ head a.txt
mv Tools.tex Tools.tex.old
mv anbe_sivam.tex anbe_sivam.tex.old
mv appendix.tex appendix.tex.old
mv bg.tex bg.tex.old
mv cc-upgrade.tex cc-upgrade.tex.old
mv chandru_bank.tex chandru_bank.tex.old
mv demo1.tex demo1.tex.old
mv ding.tex ding.tex.old
mv eso-ex2.tex eso-ex2.tex.old
mv ex4.tex ex4.tex.old

me learning perl :-)
anything better?

About this Entry

This page contains a single entry by balaji published on September 13, 2003 1:32 AM.

Mood Ring - balaji is intense was the previous entry in this blog.

Nmap Version Scanning is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.12