Mac bash 将一个目录的所有文件复制到另一个目录
Mac bash copy all files of one dir to another dir
我有一个包含两个目录的文件夹:build
和 copy-build
。
我需要通过 bash 将 copy-build
中的文件复制到 build
。
如果这些文件已经存在,则必须覆盖它们。
我试过:
cp -r ./SourceFolder ./DestFolder
但是 SourceFolder
文件夹被复制到 DestFolder
,而我需要将 SourceFolder
文件复制到 DestFolder
。
你能帮帮我吗?
使用 -R
选项而不是 -r
,并在源目录的名称中明确包含 /
。
cp -R ./SourceFolder/ ./DestFolder
来自 -R
选项的描述:
If the source_file
ends in a /, the contents of the directory are copied rather than
the directory itself.
来自 man cp
的兼容性部分:
Historic versions of the cp utility had a -r option. This implementation
supports that option; however, its use is strongly discouraged, as it
does not correctly copy special files, symbolic links, or fifo's.
假设 SourceDir
中没有子目录,您应该尝试
cp ./SourceFolder/* ./DestFolder
有关详细信息,请参阅 the manual。
我有一个包含两个目录的文件夹:build
和 copy-build
。
我需要通过 bash 将 copy-build
中的文件复制到 build
。
如果这些文件已经存在,则必须覆盖它们。
我试过:
cp -r ./SourceFolder ./DestFolder
但是 SourceFolder
文件夹被复制到 DestFolder
,而我需要将 SourceFolder
文件复制到 DestFolder
。
你能帮帮我吗?
使用 -R
选项而不是 -r
,并在源目录的名称中明确包含 /
。
cp -R ./SourceFolder/ ./DestFolder
来自 -R
选项的描述:
If the source_file ends in a /, the contents of the directory are copied rather than the directory itself.
来自 man cp
的兼容性部分:
Historic versions of the cp utility had a -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links, or fifo's.
假设 SourceDir
中没有子目录,您应该尝试
cp ./SourceFolder/* ./DestFolder
有关详细信息,请参阅 the manual。