[CentOS] script help

Phil Schaffner Philip.R.Schaffner at NASA.gov
Thu Nov 1 19:01:39 UTC 2007


On Fri, 2007-11-02 at 02:22 +0800, adrian kok wrote:
> Hi all 
> 
> how can I have script to rename the following
> directory pattern from
> 
>  
> 
> from 
> 
> dir-192.168.30.0   
> dir-192.168.30.144 
> dir-192.168.30.184
> 
> 
> To:
> 
> 
> dir-10.0.30.0   
> dir-10.0.30.144 
> dir-10.0.30.184

If you are just renaming directories, or files, and not files in
directories, the following should work:

for i in 0 144 184 ; do mv dir-192.168.30.$i dir-10.0.30.$i ; done

Or in a bit prettier form:

for i in 0 144 184
do
  mv dir-192.168.30.$i dir-10.0.30.$i
done


Phil





More information about the CentOS mailing list