linux286
Linux基础命令教程(豪华版)
作者:红联
复制文件
发布时间 :2008-03-23 11:26:30
工作的时候,有是需要保存文件的一个副本,便于以后还原。我们可以使用“cp”命令,操作如下:
[root@Linux ~]# ll
总计 64
-rw------- 1 root root 865 03-15 04:12 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 03-14 20:34 Desktop
-rw-r--r-- 1 root root 27964 03-15 04:12 install.log
-rw-r--r-- 1 root root 5069 03-15 04:11 install.log.syslog
drwxr-xr-x 2 root root 4096 03-19 12:43 one
drwxr-xr-x 2 root root 4096 03-19 12:43 two
[root@Linux ~]# cp install.log ./one
[root@Linux ~]# cd one
[root@Linux one]# ll
总计 28
-rw-r--r-- 1 root root 27964 03-19 12:55 install.log
先看看当前目录下有哪些文件,然后我们需要将install.log文件复制一份到one目录中,我们可以使用“cp
install.log ./one”就可以了,注意了,这里使用了上面的相对路径中的“.”,表示当前工作目录下的one目录。
然后进one目录,查看一下是否有intsall.log这个文件,可以看到我们已经复制了一份lnstall.log文件。
我们在来试一试,我们将目录one复制到two中,我们看看如下的操作:
[root@Linux ~]# ll
总计 64
-rw------- 1 root root 865 03-15 04:12 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 03-14 20:34 Desktop
-rw-r--r-- 1 root root 27964 03-15 04:12 install.log
-rw-r--r-- 1 root root 5069 03-15 04:11 install.log.syslog
drwxr-xr-x 2 root root 4096 03-19 12:55 one
drwxr-xr-x 2 root root 4096 03-19 12:43 two
[root@Linux ~]# cp one two
cp: 略过目录 “one”
[root@Linux ~]# cd two
[root@Linux two]# ll
总计 0
发现没有two目录下没有one文件夹,这个时候我们需要使用参数“-r”,看如下操作:
[root@Linux ~]# ll
总计 64
-rw------- 1 root root 865 03-15 04:12 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 03-14 20:34 Desktop
-rw-r--r-- 1 root root 27964 03-15 04:12 install.log
博客:http://www.linux286.com/?26040
14/31
制作于:2008-03-23 Powered by X-Space