将文件从一个目录复制到现有目录 [英] Copy files from one directory into an existing directory

查看:30
本文介绍了将文件从一个目录复制到现有目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 bash 中,我需要这样做:

In bash I need to do this:

  1. 获取目录中的所有文件

  1. take all files in a directory

将它们复制到现有目录中

copy them into an existing directory

我该怎么做?我尝试了 cp -r t1 t2(t1 和 t2 都是现有目录,t1 中有文件)但它在 t2 中创建了一个名为 t1 的目录,我不想要那个,我需要这些文件在 t1 中直接进入 t2.我该怎么做?

How do I do this? I tried cp -r t1 t2 (both t1 and t2 are existing directories, t1 has files in it) but it created a directory called t1 inside t2, I don't want that, I need the files in t1 to go directly inside t2. How do I do this?

推荐答案

你想要的是:

cp -R t1/. t2/

末尾的点告诉它复制当前目录的内容,而不是目录本身.此方法还包括隐藏文件和文件夹.

The dot at the end tells it to copy the contents of the current directory, not the directory itself. This method also includes hidden files and folders.

这篇关于将文件从一个目录复制到现有目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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