Unix questions - rename file on Unix?

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > April 2004 > rename file on Unix?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author rename file on Unix?
gogo

2004-04-11, 3:30 pm

I'd like to rename files with pattern *_new.* to files *_old.* and I
have diffuculties. The task is to rename these files in the whole
tree, not in one folder only.
I try someting like:
find ../folder *_new.* | do mv "{}" $(echo "{}"|sed s/_new/_old/g) ";"
but it does not work for me.


Any help will be appreciated.
Thansk
StAN
William Park

2004-04-11, 5:36 pm

gogo <stanlitz@hotmail.com> wrote:
> I'd like to rename files with pattern *_new.* to files *_old.* and I
> have diffuculties. The task is to rename these files in the whole
> tree, not in one folder only.
> I try someting like:
> find ../folder *_new.* | do mv "{}" $(echo "{}"|sed s/_new/_old/g) ";"
> but it does not work for me.


Try something like
find . -type f -name '*_new.*' | while read i; do
mv $i ${i/_new/_old}
done

--
William Park, Open Geometry Consulting, <opengeometry@yahoo.ca>
Linux solution/training/migration, Thin-client
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com