Linux:如果目标目录不存在,则复制并创建它
问题描述:
如果目标目录不存在,我想要一个命令(或者可能是 cp 的一个选项)来创建目标目录.
I want a command (or probably an option to cp) that creates the destination directory if it does not exist.
示例:
cp -? file /path/to/copy/file/to/is/very/deep/there
答
mkdir -p "$d" && cp file "$d"
(cp
没有这样的选项).
(there's no such option for cp
).