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. Python爬虫框架--Scrapy安装以及简单实用

    scrapy框架 框架 ​ -具有很多功能且具有很强通用性的一个项目模板 环境安装: Linux: ​        pip3 install scrapy ​ ​ ​  Windows: ​     ...

  2. 怎样学习C语言(献给迷茫的C爱好者)!

    一 .怎样学习C语言 很多人对学习C语言感到无从下手,经常问我同一个问题:究竟怎样学习C语言?我是一个教师,已经开发了很多年的程序,和很多刚刚起步的人一样,学习的第一个计算机语言就是C语言. 经过这些 ...

  3. Linux文件系统和管理-2文件操作命令(中)

    创建空文件和刷新时间 touch touch命令可以用来创建空文件或刷新文件的时间 touch 存在的文件刷新时间,不存在的文件创建空文件 生成指定日期的日志文件 [root@C8-1 ~]# dat ...

  4. JS实现页面计时

    前言 计时功能在网页上是非常多的,现在我就用原生JS做个计时功能吧 HTML <div><label>得到毫</label> <h5></h5&g ...

  5. proto文件生成对应的js和ts文件

    安装protobuf 先要安装node.js,然后用npm安装protobuf npm install -g protobufjs 生成js文件 单个文件 pbjs -t static-module ...

  6. 在PostgreSQL中CREATE STATISTICS

    如果你用Postgres做了一些性能调优,你可能用过EXPLAIN.EXPLAIN向你展示了PostgreSQL计划器为所提供的语句生成的执行计划,它显示了语句所引用的表如何被扫描(使用顺序扫描.索引 ...

  7. CyclicBarrier(循环栅栏)

    CyclicBarrier public class CyclicBarrierDemo { public static void main(String[] args) { CyclicBarrie ...

  8. pyqt5安装后 pyqt-tools却无法安装解决方法!

    逛了逛国外论坛 这哥们跟我一样 我一晚上没睡 就为了这个 原来 我的py版本太高级了 我把py3.9卸载了 换上了老旧的3.76版本 成功了

  9. hadoop使用实例

    一.词频统计 1.下载喜欢的电子书或大量文本数据,并保存在本地文本文件中 2.编写map与reduce函数 3.本地测试map与reduce 4.将文本数据上传至HDFS上 5.用hadoop str ...

  10. c++11-17 模板核心知识(一)—— 函数模板

    1.1 定义函数模板 1.2 使用函数模板 1.3 两阶段翻译 Two-Phase Translation 1.3.1 模板的编译和链接问题 1.4 多模板参数 1.4.1 引入额外模板参数作为返回值 ...