I have many directories with some phrase (domain name) in its name. Need to change that phrase to another one (another domain name). How to do that simply ? Example below:
Before:
$ ls /var/www
drwxr-x--- 12 apache apache 4096 Dec 16 10:28 somewhere.com
drwxr-xr-x 3 apache apache 4096 Jan 28 2011 maven.somewhere.com
drwxr-x--- 6 apache apache 4096 Feb 24 2010 mini.somewhere.com
drwxr-x--- 3 apache apache 4096 Jul 16 2010 ml.somewhere.com
...
After
$ ls /var/www
drwxr-x--- 12 apache apache 4096 Dec 16 10:28 elsewhere.com
drwxr-xr-x 3 apache apache 4096 Jan 28 2011 maven.elsewhere.com
drwxr-x--- 6 apache apache 4096 Feb 24 2010 mini.elsewhere.com
drwxr-x--- 3 apache apache 4096 Jul 16 2010 ml.elsewhere.com
...
$ cd /var/www
$ for i in *; do echo mv $i ${i/somewhere/elsewhere}; done
if the output looks ok:
$ for i in *; do echo mv $i ${i/somewhere/elsewhere}; done |sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With