小测试:

 [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. 关于CSS的书写规范和顺序

    关于CSS的书写规范和顺序,是大部分前端er都必须要攻克的一门关卡,如果没有按照良好的CSS书写规范来写CSS代码,会影响代码的阅读体验.这里总结了一个CSS书写规范.CSS书写顺序供大家参考,这些是 ...

  2. 使用golang插入mysql性能提升经验

    前言 golang可以轻易制造高并发,在某些场景很合适,比如爬虫的时候可以爬的更加高效.但是对应某些场景,如文件读写,数据库访问等IO为瓶颈的场合,就没有什么优势了. 前提基础 1.golang数据库 ...

  3. 02-13 Softmax回归

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

  4. python编程基础之三十

    时间模块: 时间戳:就是当前是键距离1970年1月1日0:0:0的秒数,后面还带小数,可以说是非常精确 时间的表示形式: a.以整数或者浮点数表示一个以秒为单位的时间间隔,这个时间的基础值1970.1 ...

  5. GUI tkinter (Menu)菜单项篇

    """添加顶层菜单:1.我们可以使用Menu类来新建一个菜单,Menu和其他的组件一样,第一个是parent,这里通常可以为窗口2.然后我们可以用add_command方 ...

  6. selenium3与Python3实战 web自动化测试框架 ☝☝☝

    selenium3与Python3实战 web自动化测试框架 selenium3与Python3实战 web自动化测试框架 学习 教程 一.环境搭建 1.selenium环境搭建 Client: py ...

  7. 攻防世界(XCTF)逆向部分write up(一)

    晚上做几个简单的ctf逆向睡的更好 logmein elf文件 ida看看main函数伪代码 void __fastcall __noreturn main(__int64 a1, char **a2 ...

  8. Python 之Re模块(正则表达式)

    一.简介 正则表达式本身是一种小型的.高度专业化的编程语言,而在python中,通过内嵌集成re模块,程序媛们可以直接调用来实现正则匹配. 二.正则表达式中常用的字符含义 1.普通字符和11个元字符: ...

  9. opencv实践::对象提取与测量

    问题描述 照片是来自太空望远镜的星云图像,科学家想知道它的面 积与周长. 解决思路 方法一: 通过二值分割+图像形态学+轮廓提取 #include <opencv2/opencv.hpp> ...

  10. linux下python相关命令

    若本机已安装python2,尽量不要动现有的python2,额外安装python3即可. 1.安装python3.6(centos下安装python3自带pip和setuptools) python3 ...