Linux:如果目标目录不存在,则复制并创建它 [英] Linux: copy and create destination dir if it does not exist
本文介绍了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
).
这篇关于Linux:如果目标目录不存在,则复制并创建它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文