将特定文件夹移动到新位置,并在旧位置保留符号链接到新文件夹

问题描述 投票:0回答:1

我在Archive.folder中有很多名为/var/CommuniGate/Accounts/*/的文件夹。如何将它们移动到新位置,并在旧文件夹中将符号链接保留到新位置?

也许使用find和cp来移动它们?

find /var/CommuniGate/Accounts/ -name 'Archive.folder' -exec cp -r --parents {} . \;

这对于移动它们并保持文件夹结构非常有用。但是如何与ln同时保留链接?链接也应替换旧文件夹。

shell find cp mv
1个回答
0
投票

您可以将文件移动到所需位置,然后创建符号链接:

  • mv /var/CommuniGate/Accounts/Archive.folder* new_location/
  • ln -s new_location/Archive.folder* .
© www.soinside.com 2019 - 2024. All rights reserved.