Bash:重复+重命名文件夹

Man*_*edo 3 directory bash shell rename

假设我有一个命名的文件夹my_folder_old/path/to/folder,我怎样才能创建一个名为重复my_folder_new在同一目录下?

编辑

而且如果my_folder_new已经存在,my_folder_old则在第一个内部创建而不是替换.为什么会这样?

Nop*_*lem 9

教程复制文件,文件夹链接:链接

手动cp命令:链接

cp -frp /path/to/folder/my_folder_old -T /path/to/folder/my_folder_new

   -f, --force
          if an existing destination file cannot be opened, remove it
          and try again (this option is ignored when the -n option is
          also used)
   -p     same as --preserve=mode,ownership,timestamps
   -R, -r, --recursive
          copy directories recursively
   -T, --no-target-directory
          treat DEST as a normal file
Run Code Online (Sandbox Code Playgroud)

虽然如果my_folder_new已经存在,my_folder_old将在第一个内部创建,而不是替换.为什么会这样?

之所以会发生这种情况,是因为my_folder_new已经创建了.执行相同的cp命令,它将看作新路径,/ path/to/folder/my_folder_new /