linux cp命令逻辑,Linux-CP命令
CP命令:
用来将一个或多个源文件或者目录复制到指定的目的文件或目录。它可以将单个源文件复制成一个指定文件名的具体的文件或一个已经存在的目录下。cp命令还支持同时复制多个文件,当一次复制多个文件时,目标文件参数必须是一个已经存在的目录,否则将出现错误
参数:
-a:此参数的效果和同时指定"-dpR"参数相同;
-d:当复制符号连接时,把目标文件或目录也建立为符号连接,并指向与源文件或目录连接的原始文件或目录;
-f:强行复制文件或目录,不论目标文件或目录是否已存在;
-i:覆盖既有文件之前先询问用户;
-l:对源文件建立硬连接,而非复制文件;
-p:保留源文件或目录的属性;
-R/r:递归处理,将指定目录下的所有文件与子目录一并处理;
-s:对源文件建立符号连接,而非复制文件;
-u:使用这项参数后只会在源文件的更改时间较目标文件更新时或是名称相互对应的目标文件并不存在时,才复制文件;
-S:在备份文件时,用指定的后缀“SUFFIX”代替文件的默认后缀;
-b:覆盖已存在的文件目标前将目标文件备份;
-v:详细显示命令执行的操作。
实践操作:
[root@centos7-02 /]# ls /data/
test1.txt test2.txt test3.txt test4.txt
[root@centos7-02 /]# cp /data/test1.txt /tmp/test/
[root@centos7-02 /]# tree /tmp/test/
/tmp/test/
└── test1.txt
0 directories, 1 file
[root@centos7-02 /]# cp /data/test1.txt /tmp/test/
cp:是否覆盖"/tmp/test/test1.txt"? n
[root@centos7-02 /]# \cp /data/test1.txt /tmp/test/
[root@centos7-02 /]# cp /data/test1.txt /tmp/test/
cp:是否覆盖"/tmp/test/test1.txt"? n
[root@centos7-02 /]# which cp
alias cp='cp -i'
/usr/bin/cp
[root@centos7-02 /]# /usr/bin/cp /data/test1.txt /tmp/test/
[root@centos7-02 /]#
[root@centos7-02 /]# cp -r /data/ /tmp/test/
[root@centos7-02 /]# tree tmp/test/
tmp/test/
├── data
│ ├── test1.txt
│ ├── test2.txt
│ ├── test3.txt
│ └── test4.txt
└── test1.txt
1 directory, 5 files
[root@centos7-02 /]# cp -r /data/ /tmp/test/
cp:是否覆盖"/tmp/test/data/test1.txt"? n
cp:是否覆盖"/tmp/test/data/test2.txt"? n
cp:是否覆盖"/tmp/test/data/test3.txt"? n
cp:是否覆盖"/tmp/test/data/test4.txt"? n
[root@centos7-02 /]# \cp -r /data/ /tmp/test/
[root@centos7-02 /]# tree /tmp/test/
/tmp/test/
├── data
│ ├── test1.txt
│ ├── test2.txt
│ ├── test3.txt
│ └── test4.txt
└── test1.txt
1 directory, 5 files
[root@centos7-02 /]#
特殊符号
Linux 系统中,“!” 符号或者操作符通常被用做逻辑否定的操作符,同时也通过一些调整和改动命令来从历史记录中找出你需要的命令行。
关于!几个神奇操作用法:
1.从历史记录中使用命令号来运行命令:
例如:
[root@centos7-02 /]# history
254 history
255 ! $253
256 history
257 ls /tmp/test/
258 history
[root@centos7-02 /]# !257
ls /tmp/test/
data test1.txt test2.txt
[root@centos7-02 /]#
2.执行指定的之前执行过的命令
例如:
246 tree /tmp/test/
247 cp /data/test2.txt /tmp/test/
248 echo /data/test2.txt
249 echo /tmp/test/
250 /tmp/test/
251 ls /tmp/test/
252 cp /data/test2.txt /tmp/test/
253 ls /tmp/test/
254 history
255 ! $253
256 history
257 ls /tmp/test/
258 history
259 ls /tmp/test/
260 history
261 ls /tmp/test/
262 his
263 history
[root@centos7-02 /]# !-12
cp /data/test2.txt /tmp/test/
cp:是否覆盖"/tmp/test/test2.txt"? n
[root@centos7-02 /]#
3.向一条新命令传递旧命令的参数避免重复输入(取最后一个参数)
例如:
[root@centos7-02 /]# tree /tmp/test/
/tmp/test/
├── data
│ ├── test1.txt
│ ├── test2.txt
│ ├── test3.txt
│ └── test4.txt
├── test1.txt
└── test2.txt
1 directory, 6 files
[root@centos7-02 /]# ls !$
ls /tmp/test/
data test1.txt test2.txt
[root@centos7-02 /]#
[root@centos7-02 /]# ls /tmp/test/
data test1.txt test2.txt
[root@centos7-02 /]# tree !$
tree /tmp/test/
/tmp/test/
├── data
│ ├── test1.txt
│ ├── test2.txt
│ ├── test3.txt
│ └── test4.txt
├── test1.txt
└── test2.txt
1 directory, 6 files
[root@centos7-02 /]# cp /data/test4.txt /tmp/test/
[root@centos7-02 /]# ls !$
ls /tmp/test/
data test1.txt test2.txt test4.txt
[root@centos7-02 /]#
4.用!处理两个以上的参数:
[root@centos7-02 /]# cp /data/test4.txt /tmp/test/
cp:是否覆盖"/tmp/test/test4.txt"? y
[root@centos7-02 /]# ls !$
ls /tmp/test/
data test1.txt test2.txt test4.txt
[root@centos7-02 /]# ls !cp:1
ls /data/test4.txt
/data/test4.txt
[root@centos7-02 /]# ls !cp:2
ls /tmp/test/
data test1.txt test2.txt test4.txt
[root@centos7-02 /]#
[root@centos7-02 /]# cp /data/test4.txt /tmp/test/
cp:是否覆盖"/tmp/test/test4.txt"? y
[root@centos7-02 /]# ls !^
ls /data/test4.txt
/data/test4.txt
[root@centos7-02 /]# cp /data/test4.txt /tmp/test/
cp:是否覆盖"/tmp/test/test4.txt"? y
[root@centos7-02 /]# ls !$
ls /tmp/test/
data test1.txt test2.txt test4.txt
[root@centos7-02 /]#
5.通过关键词来执行之前的命令:
[root@centos7-02 /]# !ls
ls /tmp/test/
data test1.txt test2.txt test4.txt
[root@centos7-02 /]# !cp
cp /data/test4.txt /tmp/test/
cp:是否覆盖"/tmp/test/test4.txt"? y
[root@centos7-02 /]#
linux cp命令逻辑,Linux-CP命令相关推荐
- linux逻辑文件块,Linux文件系统和逻辑卷管理命令(一)
先来介绍几个文件系统和磁盘分区相关的命令. df 命令 df 命令 用于显示某个文件所在的文件系统或者所有文件系统(默认)的信息,包括磁盘总空间大小.被占用空间大小.剩余空间大小.已用空间百分比以及挂 ...
- TIPS001:Mendeley下载全文及其命令逻辑
如何使用Mendeley下载文献全文 Mendeley的命令逻辑 Mendeley的命令逻辑和这个软件的基本定位有关,Mendleley是一个基于web的文献管理工具,故此,只是使用desktop桌面 ...
- linux下的拷贝(cp)、删除(rm)、剪切(mv)命令
linux下的拷贝(cp).删除(rm).剪切(mv)命令 2010-02-03 10:38 cp命令 该命令的功能是将给出的文件或目录拷贝到另一文件或目录中,就如同DOS下的copy命令一样,功能非 ...
- linux cp命令 前面,盘点Linux命令之Linux cp命令使用大全
Linux命令有很多,其中Linux cp命令常用的一种,Linux cp命令如何使用,下面IT培训网将为您盘点有关Linux命令之Linux cp命令大全. Linux命令之Linux cp命令详解 ...
- linux mv 环境变量,linux环境变量 cp mv 以及文档查看的几个命令
1.环境变量linux 按字面意思理解,环境能够理解为整个linux系统的环境,而变量则是一个能够变化的量或是一个命令.vim 那么,咱们就能够理解为linux的环境变量,就是针对于linux的整个系 ...
- linux命令中的cp,Linux高级技术:关于cp命令中拷贝所有的写法
Linux高级技术:关于cp命令中拷贝所有的写法 发布时间:2007-09-30 21:39:36来源:红联作者:GiftPot 今天在编写一个脚本的时候,发现一个比较奇怪的问题:就是在使用cp拷贝当 ...
- linux 不同电脑cp,linux命令:拷贝命令家族(cp、scp、rsync)
Linux命令中:rsync和cp之间的区别 - 小 楼 一 夜 听 春 雨 - 博客园 https://www.cnblogs.com/kex1n/p/7008178.html cp,scp,rsy ...
- linux cp -r 参数,Linux系统中cp命令的参数及用法详解
Linux系统中cp命令主要是用来复制文件或者目录.下面由学习啦小编为大家整理了Linux系统中cp命令的参数及用法详解的相关知识,希望对大家有帮助! Linux系统中cp命令的参数及用法详解:参数说 ...
- linux cp 全覆盖,Linux中使用cp命令进行强制覆盖的方法
cp在拷贝时,如果遇到相同的文件名的文件,就会不断询问是否覆盖,让你输入yes or no .为什么呢?这是为了linux为了安全考虑,在cp命令上用了别名.也就是你输入只是输入cp命令时,其实系统是 ...
最新文章
- 近期神奇机器学习应用大赏
- 世界上最美丽的23个公式
- 让Dev-C++运行C++程序的控制台窗口等待查看运行结果
- expected unqualified-id before numeric constant问题原因
- Qt中的QMainWindow
- SpringCloud(第一部分)
- 本地区间管理 oracle,Oracle:本地表空间管理,字典表空间管理
- C++实现堆排序(附完整源码)
- BeetleX之vue-autoui自匹配UI插件
- 基于CefSharp构建基于Chromium的应用程序
- 正睿2019省选附加赛 Day10 (这篇其实已经都咕咕了...)
- 平滑线反锯齿工具_Photoshop中的华丽渐变工具的使用
- 桌面云之深信服VDC管理
- HTML简易自适应布局
- 学会这5种排版方式,设计能力分分钟就能提高
- 无法处理文件 Snoop\Forms\BindingMap.resx,因为它位于 Internet 或受限区域中,或者文件上具有 Web 标记。要想处理这些文件,请删除 Web 标记。
- redis 集群详解及搭建过程
- 传输层安全协议TLS/SSL
- html怎样实现动态背景效果,利用jQuery实现动态背景特效
- excel 画散点图 怎么设置图片的分辨率_【R语言】barplot柱状图+散点图+误差棒