将目录文件复制到另一个目录的问题

时间:2020-06-08 01:32:44

标签: bash

所以我想将一些文件从一个目录复制到另一个目录。
本质上,我想捕获变量的目录路径,例如“ pathname”,并使用
“ cp-r $ pathname。”将file1和file2复制到我使用mkdir制作的新文件夹中,并将其cd到其中(因此将“。”作为第二个命令行参数)。

source_to_copy_from:

home/folder1/folder2/file1
home/folder1/folder2/file2

destination_to_copy_to:

home/newfolder1/newfolder2/file1
home/newfolder1/newfolder2/file2

我做到了:

pathname=$"$(pwd)"
//code to make the newfolder1 here
cp -r $"$pathname" .

但是新路径名中似乎没有任何内容可以复制。
也在使用Mac bash
也是初学者bash

0 个答案:

没有答案