Bash 附加到终端中的目录
我想将新文件附加到终端中的现有目录。所以我使用:Bash 附加到终端中的目录,bash,terminal,copy,Bash,Terminal,Copy,我想将新文件附加到终端中的现有目录。所以我使用: cp -r pathtodirectory/directory/ directory 但我不想覆盖,我只想更新。有什么想法吗 find pathtodirectory/directory -maxdepth 1 -type f -exec sh -c \ 'for f; do ff="directory/$(basename $f)"; if [[ ! -f "$ff" ]]; then echo "Copying $f" &&
cp -r pathtodirectory/directory/ directory
但我不想覆盖,我只想更新。有什么想法吗
find pathtodirectory/directory -maxdepth 1 -type f -exec sh -c \
'for f; do ff="directory/$(basename $f)"; if [[ ! -f "$ff" ]]; then echo "Copying $f" && cp "$f" "$ff"; fi; done' sh {} +
限制:
- 文件名中没有空格/全局字符
(GNU coreutils)5.97中缺少此功能