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. C++11随机数库

    random随机数库 C++11引入了新的随机数生成机制,那就是<random>随机数库,支持多种伪随机数生成算法,多种连续和离散随机数分布算法,以及封装了真正的随机数生成引擎random ...

  2. ubuntu vi编辑器上下左右为ABCD的解决办法

    这个ubuntu系统自带的vi版本太老导致的,所以解决办法就是安装新版的vi编辑器: 首先卸载旧版本的vi编辑器: $sudo apt-get remove vim-common 然后安装新版的vi: ...

  3. centos8上使用lsblk查看块设备

    一,查看lsblk命令所属的rpm包 [root@yjweb ~]# whereis lsblk lsblk: /usr/bin/lsblk /usr/share/man/man8/lsblk.8.g ...

  4. 在windows2003上安装itunes

    本人使用windows server 2003系统 安装itunes时提示 AppleMobileDeviceSupport 只能按照在xp系统上或以上版本,你可以忽略这个错误.继续安装吧. 这样除了 ...

  5. 洛谷 P6602 数轴

    时光倒流+暴力+尺取 第一次看到这题,是在神子杏的课堂上 这就是一个裸的双指针,洛咕上多倍经验的题太多了. --神子杏 那好,我们就用双指针来考虑这道题. 首先可以发现 答案区间$ (l,r) $ 一 ...

  6. 【应用服务 App Service】App Service 中部署Java应用中文乱码现象

    问题情形 有时候部署在 Azure  App Service的 Java应用会出现乱码 详细日志 无 问题原因 因为 App Service默认的编码为gbk,所以在显示页面或传递中文字符时就会出现乱 ...

  7. EFS加密

    目录 EFS简介 EFS的特点 EFS的缺陷 EFS证书 证书的导出 证书的安装 EFS加密 方法一 方法二 EFS简介 EFS(Encrypting File System,加密文件系统)是Wind ...

  8. .net core autofac asyncinterceptor 异步拦截器开发

    autofac使用拦截器实现AOP,是基于Castle.Core的.然而Castle.Core并未提供原生异步支持.所以需要使用帮助类实现,这在autofac官方文档的已知问题中有详细说明: http ...

  9. 使用 Azure静态web应用+Github全自动部署VUE站点

    什么事Azure静态web应用 Azure 静态 Web 应用是一种服务,可从 GitHub 存储库自动构建完整的堆栈 Web 应用,并将其部署到 Azure,目前它还是预览版. Azure 静态 W ...

  10. CSS常见标签类型

      块级(block): div,ul,li,h1~h6,p 独自占据一行 可设置宽高 行内(inline): span,a 占据所设置字体大小 不可设置宽高 上下margin值不会占用空间 行内块( ...