Linux系统:复制和创建目标目录。如果它不存在 [英] Linux: copy and create destination dir if it does not exist
本文介绍了Linux系统:复制和创建目标目录。如果它不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建目标目录,如果不存在,一个命令(或者可能是一个选项,以CP)。
例如:
CP - ?文件/路径/要/复印/文件/至/是/非常/深/有
解决方案
测试-d$ D|| MKDIR -p$ D&放大器;&安培; CP文件$ D
(有没有为这样的选项 CP
)。
I want a command (or probably an option to cp) that creates the destination directory if it does not exist.
Example:
cp -? file /path/to/copy/file/to/is/very/deep/there
解决方案
test -d "$d" || mkdir -p "$d" && cp file "$d"
(there's no such option for cp
).
这篇关于Linux系统:复制和创建目标目录。如果它不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文