访问手机版  

Linux常用命令|Linux培训学习|考试认证|工资待遇与招聘,认准超级网工!

招聘|合作 登陆|注册

网络工程师培训

当前位置:网络工程师 > 技术课程 > linux > 热点关注 > linux常用命令

linux常用命令 我使用过的Linux命令之cp

时间:2018-09-11

linux常用命令_linux常用命令vim_linux和windows的区别

cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一。一般情况下,shell会设置一个别名,在命令行下复制文件时,如果目标文件已经存在,就会询问是否覆盖,不管你是否使用-i参数。但是如果是在shell脚本中执行cp时,没有-i参数时不会询问是否覆盖。这说明命令行和shell脚本的执行方式有些不同。

[root@jfht ~]# type -a cp

cp is aliased to `cp -i' <== 在命令行状态,cp实际上是个别名

cp is /bin/cp

[root@jfht ~]#

-i 询问是否覆盖。

-f 强制覆盖,但如果有-i参数时,此参数无效。

-r 递归复制。

-a 递归复制,并且保留文件的时间、权限、属主等属性。

[root@jfht ~]# ls >ls0.txt

[root@jfht ~]# ls -l ls0.txt

10-18 20:39:41。

10-18 20:45:41。

[2014-10-18 20:57:41]。

[01:10.71][02:20.62][03:10.18][03:41.69]要怎么永远。

等待两分钟再操作。linux常用命令因为同一分钟看不出效果。

[root@jfht ~]# cp ls0.txt ls1.txt

[root@jfht ~]# ls -l ls0.txt ls1.txt

-rw-r--r-- 1 root root 213 10-18 20:41 ls0.txt

10-18 20:08:43。

10-18 20:43:18。

10-18 20:55:43。

[唯美音画]尘封一种心境《秘密》flash(2008-10-18 20:43:26)[499]。

在没有带-a参数时,两个文件的时间是不一样的。

[root@jfht ~]# cp -a ls0.txt ls2.txt

[root@jfht ~]# ls -l ls0.txt ls2.txt

-rw-r--r-- 1 root root 213 10-18 20:41 ls0.txt

-rw-r--r-- 1 root root 213 10-18 20:41 ls2.txt

在带了-a参数时,两个文件的时间是一致的。

[root@jfht ~]# cp ls0.txt ls2.txt

cp:是否覆盖“ls2.txt”? n

目标文件存在时,会询问是否覆盖。这是因为cp是cp -i的别名。

[root@jfht ~]# cp -f ls0.txt ls2.txt

cp:是否覆盖“ls2.txt”? n

目标文件存在时,即使加了-f标志,也还会询问是否覆盖。linux常用命令

[root@jfht ~]# command cp ls0.txt ls2.txt

使用command命令执行cp时,就不会执行cp别名了,而是直接执行cp外部命令。

[root@jfht ~]# ls -l ls0.txt ls2.txt

linux常用命令_linux和windows的区别_linux常用命令vim

-rw-r--r-- 1 root root 213 10-18 20:41 ls0.txt

10-18 20:31:48。

-rwxr-xr-x 1 root root 1485 8月 22 10:18 realserver.sh 。

倪发建·2016-10-18 20:48·11·1043无论直通车什么质量分,都是为了提高点击量,而点击量反作用于质量分。

人气指数: 10 大小: 700 kb 类别: 聊天工具 日期: 2013-10-18 11:48:00。

[root@jfht ~]# cp ls0.txt ls0.txt