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. java怎么产生随机数

    随机数的产生在一些代码中很常用,也是我们必须要掌握的.而java中产生随机数的方法主要有三种: 第一种:new Random() 需要借助java.util.Random类来产生一个随机数发生器,也是 ...

  2. .Net Core中使用Grpc

    一.Grpc概述 gRPC 基于如下思想:定义一个服务, 指定其可以被远程调用的方法及其参数和返回类型.gRPC 默认使用protocol buffers作为接口定义语言,来描述服务接口和有效载荷消息 ...

  3. 第二十五章 ansible基础

    一.Ansible概述 1.什么是Ansible Ansible是一个自动化统一配置管理工具,自动化主要体现在Ansible集成了丰富模块以及功能组件,可以通过一个命令完成一系列的操作,进而能减少重复 ...

  4. Linux-京西百花山

    百花山有三个收票的入口,分别在门头沟(G109).房山(G108)和河北 108有两个方向上百花山,史家营和四马台.只有史家营方向能开车到山顶. 四马台那边,不住,要坐景区车才行 尽头是1900多米的 ...

  5. SQL DELETE语句如何让表使用别名的方法

    DELETE 别名 FROM 表名称 别名 WHERE 列名称 = 值

  6. 抽空学学KVM(七):虚拟机快照和克隆

    前几天学写了KVM中qume-info命令的使用,今天学学在虚拟化里面用处广泛的快照和克隆功能,snapshot和virt-clone.对于snapshot命令的使用其实很简单.进入virsh界面以后 ...

  7. xlrd加载Excal表格编码格式的问题

    Python自动化测试中,利用xlrd加载文件名,代码如下: newpath = os.chdir('文件所在目录') filename = "文件名.xlsx" 报IOError ...

  8. 专攻知识小点——回顾JavaWeb中的servlet(三)

    HttpSession基本概述 ** ** 1.HttpSession:是服务器端的技术.和Cookie一样也是服务器和客户端的会话.获得该对象是通过HTTPServletRequest的方法getS ...

  9. 续 Eureka+Hystrix+Zuul(Zuul API网关)

    概述: 服务的合并,转发,验证,异构协议.将上百个请求融为一个发送到后台,返回大的JSON返回处理: 作用:这减少了客户端与应用程序间的交互次数,还简化了客户端代码. Zuul可以通过加载动态过滤机制 ...

  10. git 移除远程仓库关联

    1 git remote rm origin // 移除本地关联 2 git remote add origin git@github.com/example.git // 添加线上仓库 3 git ...