Linux下如何复制,但不覆盖? [英] Linux how to copy but not overwrite?

查看:1922
本文介绍了Linux下如何复制,但不覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想 CP 目录,但我不希望覆盖任何现有的文件,即使是它们比复制的文件旧。我想这样做完全noniteractive因为这将是一个crontab Bash脚本的一部分。任何想法?

I want to cp a directory but I do not want to overwrite any existing files even it they are older than the copied files. And I want to do it completely noniteractive as this will be a part of a Crontab Bash script. Any ideas?

推荐答案

从的手册页

-n, --no-clobber
              do not overwrite an existing file (overrides a previous -i option)

例如:

cp -n myoldfile.txt mycopiedfile.txt

这篇关于Linux下如何复制,但不覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆