touch或>命令创建普通文件:

[root@localhost test]# touch a  ---创建单个文件
[root@localhost test]# ls
a
[root@localhost test]# > b   ---创建单个文件
[root@localhost test]# ls
a  b
 
mkdir创建目录文件:
[root@localhost test]# mkdir c  --创建文件夹
[root@localhost test]# ll
total 0
-rw-r--r-- 1 root root 0 Oct  1 19:54 a
-rw-r--r-- 1 root root 0 Oct  1 19:54 b
drwxr-xr-x 2 root root 6 Oct  1 19:55 c
 
一次创建多个普通文件:
[root@localhost test]# touch d e 
---创建多个文件
[root@localhost test]# ls
a  b  c 
d  e
 
选项-p递归创建多个目录文件:
[root@localhost test]# mkdir -p aa/bb 
---使用-p递归创建目录
[root@localhost test]# ll
total 0
-rw-r--r-- 1 root root  0
Oct  1 19:54 a
drwxr-xr-x 3 root root 16 Oct  1 19:57
aa
-rw-r--r-- 1 root root  0
Oct  1 19:54 b
drwxr-xr-x 2 root root  6
Oct  1 19:55 c
-rw-r--r-- 1 root root  0
Oct  1 19:55 d
-rw-r--r-- 1 root root  0
Oct  1 19:55 e
[root@localhost test]# cd aa
[root@localhost aa]# ls
bb
 
选项-R递归显示文件:
[root@localhost test]# ls -R 
----使用选项-R递归显示文件。
.:
a  aa  b 
c  d  e
./aa:
bb
./aa/bb:
./c:
[root@localhost test]# mkdir -pv cc/dd 
--v指verbose。详细显示递归创建。
mkdir: created directory ?.c?
mkdir: created directory ?.c/dd?
 
cp拷贝单个普通文件:
[root@localhost test]# ll
total 0
-rw-r--r-- 1 root root  0
Oct  1 19:54 a
drwxr-xr-x 3 root root 16 Oct  1 19:57
aa
-rw-r--r-- 1 root root  0
Oct  1 19:54 b
drwxr-xr-x 2 root root  6
Oct  1 19:55 c
drwxr-xr-x 3 root root 16 Oct  1 20:00
cc
-rw-r--r-- 1 root root  0
Oct  1 19:55 d
-rw-r--r-- 1 root root  0
Oct  1 19:55 e
[root@localhost test]# cp a f
[root@localhost test]# ll
total 0
-rw-r--r-- 1 root root  0
Oct  1 19:54 a
drwxr-xr-x 3 root root 16 Oct  1 19:57
aa
-rw-r--r-- 1 root root  0
Oct  1 19:54 b
drwxr-xr-x 2 root root  6
Oct  1 19:55 c
drwxr-xr-x 3 root root 16 Oct  1 20:00
cc
-rw-r--r-- 1 root root  0
Oct  1 19:55 d
-rw-r--r-- 1 root root  0
Oct  1 19:55 e
-rw-r--r-- 1 root root  0
Oct  1 20:02 f
 
cp拷贝多个普通文件:
[root@localhost test]# cp a b aa
[root@localhost test]# cd aa
[root@localhost aa]# ll
total 0
-rw-r--r-- 1 root root 0 Oct  1 20:04 a
-rw-r--r-- 1 root root 0 Oct  1 20:04 b
drwxr-xr-x 2 root root 6 Oct  1 19:57
bb
 
cp加选项-r拷贝目录文件:
[root@localhost test]# ll
total 0
-rw-r--r-- 1 root root  0
Oct  1 19:54 a
drwxr-xr-x 3 root root 34 Oct  1 20:04
aa
-rw-r--r-- 1 root root  0
Oct  1 19:54 b
drwxr-xr-x 2 root root  6
Oct  1 19:55 c
drwxr-xr-x 4 root root 26 Oct  1 20:07
cc
-rw-r--r-- 1 root root  0
Oct  1 19:55 d
-rw-r--r-- 1 root root  0
Oct  1 19:55 e
-rw-r--r-- 1 root root  0
Oct  1 20:02 f
[root@localhost test]# cp -r aa cc
[root@localhost test]# cd cc
[root@localhost cc]# ll
total 0
drwxr-xr-x 3 root root 34 Oct  1 20:07
aa
drwxr-xr-x 2 root root  6
Oct  1 20:00 dd
 
cp拷贝普通文件并重命名:
[root@localhost test]# cp a ./bb/1
[root@localhost test]# ls ./bb
1
 
mv剪切文件:
剪切文件没有-r之分,无论是普通文件还是目录都不用加-r.,不用区分普通文件还是目录文件,可以一次剪切多个文件.也有重命名的作用.
[root@localhost test]# ls
a  aa 
b  bb  c 
cc  d  e 
f
[root@localhost test]# mv b g
[root@localhost test]# ls
a  aa 
bb  c  cc 
d  e  f  g
 
rm删除文件:
[root@localhost test]# ls
a  aa  bb 
c  cc  d 
e  f  g
[root@localhost test]# rm -fr a
[root@localhost test]# ls
aa  bb  c 
cc  d  e 
f  g
[root@localhost test]# rm -fr ? ---使用统配符?代表单个字符的文件
[root@localhost test]# ls
aa  bb  cc
[root@localhost test]# rm -fr * 
--使用统配符*,代表所有文件

linux文件增删拷(touch/mkdir/cp/mv/rm)的更多相关文章

  1. 快捷键,命令之tab/ history / alias / ls / cd / mkdir / touch /tree /cp /mv /rm /cat /head/grep

    第一阶段 快捷键 1 第二阶段 文件和目录操作命令 1 1.1 date / useradd 1 1.2 echo 调用变量 2 1.3 whoami 查看用户名 2 1.4 tab命令补全 2 1. ...

  2. Linux文件与目录管理 - ls, cp, mv

    [root@www ~]# ls [-aAdfFhilnrRSt] 目录名称 [root@www ~]# ls [--color={never,auto,always}] 目录名称 [root@www ...

  3. ubuntu文件操作mkdir cp mv rm ln

    pwd:显示当前目录 date:显示当前日期 cal:显示日历 ls:列出目录内容 cd:改变当前工作目录 ‘.’:代表工作目录 ‘..’:代表工作目录父目录 进入当前目录的父目录:cd /home ...

  4. 自学Linux Shell3.4-文件处理命令touch cp mv rm

    点击返回 自学Linux命令行与Shell脚本之路 3.4-文件处理命令touch cp mv rm 1. touch命令 一是用于把已存在文件的时间标签更新为系统当前的时间(默认方式),它们的数据将 ...

  5. linux基本命令之文件浏览(cat,more,less,tail,head),文件操作命令(cp,mv,rm,find)

    linux文件浏览,文件操作命令 文件管理之文件浏览命令 1.cat命令:显示文本文件所有内容 格式:cat 文件名 适用场景:适合只有少量数据的文件,例如只有几行内容的可以使用此命令. 2.more ...

  6. cp | mv | rm

    linux下文件的复制.移动与删除命令为:cp,mv,rm 一.文件复制命令cp 命令格式: cp [-adfilprsu] 源文件(source) 目标文件(destination) cp [opt ...

  7. Linux学习--第三天--linux文件目录、ls、mkdir、mv、rm、touch、cat、tac、more、less、head、tail、ln、chmod、chown、chgrp、umask

    文件目录 目录名 备注 bin 下面的命令所有人都可以运行 sbin 只有root才能运行,s代表super /mnt,/media,/misc 都是挂载目录,但一般只用mnt /opt 第三方软件安 ...

  8. linux笔记:目录处理命令ls,mkdir,cd,pwd,rmdir,cp,mv,rm

    linux命令的格式:命令 [-选项] [参数]例:ls -la /etc 命令:ls命令所在路径:/bin/ls功能:显示目录文件用法:ls [-aldh] []参数:-a 查看所有文件,包括隐藏文 ...

  9. linux文件系统命令(6)---touch和mkdir

    一.目的 本文将介绍linux下新建文件或文件夹.删除文件或文件夹命令.         touch能够新建文件,mkdir用来新建文件夹.rm用来删除文件或文件夹.         本文将选取ubu ...

随机推荐

  1. day18 Pyhton学习 匿名函数

    匿名函数 别称: lambda表达式 函数,没有名字 def wahaha(n):#wahaha return n**2 print(wahaha.__name__) qqxing = lambda ...

  2. .net c#后台请求接口

    我们在请求接口的时候,有时因为跨域的问题,总是请求接口失败,亦或是请求接口时,页面还存在跳转的问题,这个时候,我们通过前台ajax请求自己的一般处理程序,用一般处理程序请求客户提供的接口 //获取to ...

  3. Hash算法简介

    Hash算法性质 Hash算法用于计算消息摘要(Message Digest),可以将任意长的输入信息快速地转换为固定长度的输出.在区块链中主要利用了Hash算法的三种性质: 抗冲突性(Collisi ...

  4. 编程福利:50本C语言电子书,你还怕没书看吗!

    推荐适合编程新手入门的几本经典的C语言书籍. 1.<C程序设计语言> C语言之父的著作,被称为C语言的的圣经.全球最经典的C语言教程.这本书最大的特点是精炼.读起来不会觉得"啰嗦 ...

  5. Linux发行版教你如何选 给入门者的选择通法

    Linux的发行版何止琳琅满目,简直是乱入你眼. 本篇将介绍选择发行版的经验和通用法则,主要会从PC角度去谈. 更新于2020年,初次发布于2017年 选择发行版需考虑哪些因素 选择发行版时需要考虑的 ...

  6. 面试官:如何写出让 CPU 跑得更快的代码?

    前言 代码都是由 CPU 跑起来的,我们代码写的好与坏就决定了 CPU 的执行效率,特别是在编写计算密集型的程序,更要注重 CPU 的执行效率,否则将会大大影响系统性能. CPU 内部嵌入了 CPU ...

  7. spring注解@Transactional 和乐观锁,悲观锁并发生成有序编号问题

      需求:系统中有一个自增的合同编号,在满足并发情况下,生成的合同编号是自增的. 测试工具:Apache Jmeter 实现方法: 创建一个数据库表.编号最大值记录表 表结构类似 CREATE TAB ...

  8. js后台提交成功后 关闭当前页 并刷新父窗体

    后台提交成功后 关闭当前页 并刷新父窗体 this.ClientScript.RegisterStartupScript(this.GetType(), "message", &q ...

  9. <!DOCTYPE>,<address>,<applet>的用法

    希望以下内容能让大家有所收获 HTML <!DOCTYPE> 标签 实例 <!DOCTYPE html> <html> <head> <title ...

  10. Python基础知识点整理(详细)

    Python知识点整理(详细) 输出函数 print()可以向屏幕打印内容,或者在打开指定文件后,向文件中输入内容 输入函数 input([prompt])[prompt] 为输入的提示字符.该函数返 ...