[CentOS] script help

Ross S. W. Walker rwalker at medallion.com
Fri Nov 2 14:20:10 UTC 2007

Michael D. Kralka wrote:
> Ross S. W. Walker wrote:
> > 
> > Try:
> > 
> > # find <parent dir> -type d -name dir-192.168.\* -exec mv \{\} `echo
> > \{\} | sed 's/192\.168\./10\.0\./'` \;
> > 
> > That should recursively rename all directories from one 
> naming scheme to
> > another.
> ... except for the fact that the `echo \{\} ...` will be evaluated by
> the shell and not find, so this is the same as:
> find <parent dir> -type d -name dir-192.168.\* -exec mv \{\} \{\} \;
> Not very useful ;)

Yes, thanks for pointing that out, it would have to be put into a
loop then.

# for dir in `find <parent dir> -type d -name dir-192.168.\* -print`; do
# mv $dir `echo $dir | sed 's/192\.168\./10\.0\./'`
# done

I also just saw the earlier post on the 'rename' command which does it
all for the OP and should be a lot faster then a shell script.


This e-mail, and any attachments thereto, is intended only for use by
the addressee(s) named herein and may contain legally privileged
and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination,
distribution or copying of this e-mail, and any attachments thereto,
is strictly prohibited. If you have received this e-mail in error,
please immediately notify the sender and permanently delete the
original and any copy or printout thereof.

More information about the CentOS mailing list