小测试:

 [root@test test]# ls
[root@test test]# touch -abc
touch: invalid option -- 'b'
Try `touch --help' for more information.
[root@test test]# touch -m
touch: missing file operand
Try `touch --help' for more information.
[root@test test]# mkdir --hello
mkdir: unrecognized option '--hello'
Try `mkdir --help' for more information.
[root@test test]# mkdir -world
mkdir: invalid option -- 'w'
Try `mkdir --help' for more information.
[root@test test]#
[root@test test]# ls
[root@test test]#
[root@test test]# mkdir -- -world
[root@test test]# ls
-world
[root@test test]# touch -- -abc
[root@test test]# ls
-abc -world
[root@test test]# rm -f -abc
rm: invalid option -- 'a'
Try `rm ./-abc' to remove the file `-abc'.
Try `rm --help' for more information.
[root@test test]#
[root@test test]# rm -fr -world/
rm: invalid option -- 'w'
Try `rm ./-world/' to remove the file `-world/'.
Try `rm --help' for more information.
[root@test test]# rm -fr -- -abc
[root@test test]# ls
-world
[root@test test]# rm -fr -- -world/
[root@test test]#
[root@test test]#
[root@test test]# mkdir -- -hello
[root@test test]# ls
-hello
[root@test test]# rm -fr * # 连通配符都搞不定
rm: invalid option -- 'h'
Try `rm ./-hello' to remove the file `-hello'.
Try `rm --help' for more information. 补充:

[root@test test]# rm -fr -- *
[root@test test]# ls
[root@test test]#

 

man rm 的说明

man getopts 的说明

小结:

  1、-- 就相当于 转义字符斜杠 \ 的效果

  2、没发现创建的这样的目录或文件有什么应用场景,了解即可

Linux 如何创建或删除以横杠(-)开头的文件或目录的更多相关文章

  1. linux下创建和删除软、硬链接

    linux下创建和删除软.硬链接 在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件时,索引结点被复制 ...

  2. Git 创建点开头的文件和目录

    Git 创建点开头的文件和目录 # 创建 .gitignore 文件 1@DESKTOP-3H9092J MINGW64 /e/x1/x1/demo1 (master) $ echo .idea &g ...

  3. mysql数据库创建删除带横杠的数据库名

    mysql> create database d-d; ERROR 1064 (42000): You have an error in your SQL syntax; check the m ...

  4. Linux下创建和删除软、硬链接 可临时处理空间不足

    在Linux系统中,内核为每一个新创建的文件分配一个Inode(索引结点),每个文件都有一个惟一的inode号.文件属性保存在索引结点里,在访问文件时,索引结点被复制到内存在,从而实现文件的快速访问. ...

  5. Linux下创建和删除用户

    在Linux下创建用户和删除用户,必须在root用户下,如果你当前不是用根用户登录,你可以打开终端,输入"su root"命令,再输入根口令,就可以进入root用户模式下,如下所示 ...

  6. linux(2)文件和目录管理(新增,删除,复制,移动,文件和目录权限,文件查找)

    一.目录与路径 1.相对路径与绝对路径绝对路径:/开头, cd /usr相对路径:cd ../..2.目录操作(cd:change directory).:当前目录..:上一层目录-:上一个目录~:当 ...

  7. Linux(centos)新建,删除,移动,重命名文件夹和文件的命令

    1.新建文件夹 mkdir 文件名 新建一个名为test的文件夹在home下 view source1 mkdir /home/test 2.新建文本 在home下新建一个test.sh脚本 vi / ...

  8. 用Linux命令行实现删除和复制指定类型的文件

    (一)Linux 删除当前目录及子目录中所有某种类型的文件 方法1 : 此方法不能处理目录中带空格的那些. rm -rf `find . -name "*.example"` Li ...

  9. linux基础命令--userdel 删除用户帐户和相关文件

    描述 userdel命令用于删除用户帐户和相关文件. userdel命令修改系统账户文件,删除所有涉及用户的信息,指定的用户(LOGIN)必须存在. 语法 userdel [options] LOGI ...

随机推荐

  1. 简单动态字符串(SDS)

    SDS 前提:在redis中,C字符串只会作为字符串字面量用在一些无须对字符串进行修改的地方,比如打印日志: redisLog(REDIS_WARNING, “Redis is ready to ex ...

  2. 02-13 Softmax回归

    目录 Softmax回归 一.Softmax回归详解 1.1 让步比 1.2 不同类之间的概率分布 1.3 目标函数 1.4 目标函数最大化 二.Softmax回归优缺点 2.1 优点 2.2 缺点 ...

  3. 一文了解 Redis 内存监控和内存消耗

    Redis 是一种内存数据库,将数据保存在内存中,读写效率要比传统的将数据保存在磁盘上的数据库要快很多.所以,监控 Redis 的内存消耗并了解 Redis 内存模型对高效并长期稳定使用 Redis ...

  4. Web性能优化:雅虎35条

    对web性能优化,一直知道是个很重要的方面,平时有注意到,但是对于雅虎35条是第一次听说,查了一下,发现平时都有用过,只是没有总结到一块,今天就总结一下吧. 雅虎35条: 1.[内容]尽量减少HTTP ...

  5. Redis之安装配置(Windows)

    下载 下载地址:https://github.com/MSOpenTech/redis/releases 解压,文件的名字重命名为redis. 打开文件夹,内容如下: 发送redis-server.e ...

  6. linux 防火墙基本使用

    写在最前面 由于工作后,使用的Linux就是centos7 所以,本文记录是是centos7的防火墙使用. 从 centos7 开始,系统使用 firewall 进行防火墙的默认管理工具. 基本使用 ...

  7. python入门之jieba库的使用

    对于一段英文,如果希望提取其中的的单词,只需要使用字符串处理的split()方法即可,例如“China is a great country”.   然而对于中文文本,中文单词之间缺少分隔符,这是中文 ...

  8. python soket服务和客户端Demo

    #服务端from socket import * s=socket(AF_INET,SOCK_STREAM)#IVP4 寻址 tcp协议 s.bind(('',6666))#补丁端口 s.listen ...

  9. pycharm中常见错误提示

    1.类中定义函方法 PyCharm 提示Method xxx may be 'static': 原因:该方法不涉及对该类属性的操作,编译器建议声明为@staticmethod

  10. CentOS7使用‘中科大源’

    中科大的源质量速度都不错,推荐使用. 这里列出CentOS 7的Base和epel的源. 进入/etc/yum.repos.d/中,将原本的几个repo文件备份,之后新建三个repo文件 内容如下: ...