加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 用一个域名将多个目录重命名为另一个域名?

发布时间:2020-12-14 01:35:06 所属栏目:Linux 来源:网络整理
导读:我的名字中有许多目录,其中包含一些短语(域名).需要将该短语更改为另一个(另一个域名).怎么这么简单?示例如下: 之前: $ls /var/wwwdrwxr-x--- 12 apache apache 4096 Dec 16 10:28 somewhere.comdrwxr-xr-x 3 apache apache 4096 Jan 28 2011 maven.somew
我的名字中有许多目录,其中包含一些短语(域名).需要将该短语更改为另一个(另一个域名).怎么这么简单?示例如下:

之前:

$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
...

$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

如果输出看起来不错:

$for i in *; do echo mv $i ${i/somewhere/elsewhere}; done |sh

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读