黑马《linux基础编程》学习笔记(从6到10)

六. 绝对路径和相对路径

 

 七. ls和常用参数

八. cd和pwd命令

九. rm命令

十. cp命令

实验操作

//建立空的文件夹test
[root@VM_0_15_centos home]# mkdir test
[root@VM_0_15_centos home]# cd test
[root@VM_0_15_centos test]# ls

//文件夹中建立hello.txt这个文件
[root@VM_0_15_centos test]# touch hello.txt
[root@VM_0_15_centos test]# ls
hello.txt

//情况一: cp 要拷贝的文件(file) file1(不存在)
//结果:创建file1,并将file的内容拷贝到file1
[root@VM_0_15_centos test]# cp hello.txt target
[root@VM_0_15_centos test]# ls
hello.txt  target

//情况二: cp 要拷贝的文件(file) file1(存在)
//结果:file的内容覆盖file1的内容
[root@VM_0_15_centos test]# cp hello.txt target
[root@VM_0_15_centos test]# vi target


//情况三: cp file dir(存在)
//结果:拷贝file到dir目录
[root@VM_0_15_centos test]# mkdir son
[root@VM_0_15_centos test]# ls
hello.txt  son  target
[root@VM_0_15_centos test]# cp hello.txt son
[root@VM_0_15_centos test]# ls
hello.txt  son  target
[root@VM_0_15_centos test]# cd son
[root@VM_0_15_centos son]# ls
hello.txt


//情况四: cp dir(存在)dir1(存在)
//结果:将dir目录拷贝到dir1,包括dir目录
[root@VM_0_15_centos son]# cd ..
[root@VM_0_15_centos test]# ls
hello.txt  son  target
[root@VM_0_15_centos test]# mkdir son2
[root@VM_0_15_centos test]# cp son son2 -r
[root@VM_0_15_centos test]# ls
hello.txt  son  son2  target
[root@VM_0_15_centos test]# cd son2
[root@VM_0_15_centos son2]# ls
son
[root@VM_0_15_centos son2]# cd ..
[root@VM_0_15_centos test]# tree son2
son2
`-- son
    `-- hello.txt


//情况五: cp dir(存在)dir1(不存在)
//结果:创建dir1,将dir目录拷贝到dir1,不包括dir目录
1 directory, 1 file
[root@VM_0_15_centos test]# ls
hello.txt  son  son2  target
[root@VM_0_15_centos test]# cp son a
cp: omitting directory ‘son’
[root@VM_0_15_centos test]# cp son a -r
[root@VM_0_15_centos test]# ls
a  hello.txt  son  son2  target
[root@VM_0_15_centos test]# tree a
a
`-- hello.txt

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值