V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
tywtyw2002
V2EX  ›  问与答

求助在 linux 下如何删除这样一个奇葩文件

  •  
  •   tywtyw2002 · 2015-03-03 01:20:37 +08:00 · 6034 次点击
    这是一个创建于 3343 天前的主题,其中的信息可能已经有所发展或是发生改变。
    文件名是这样的 `-.facebook.com`


    tyw@CosHiM-EMC:~|⇒ rm -rf -.facebook.com
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    Try 'rm --help' for more information.

    tyw@CosHiM-EMC:~|⇒ ls
    17.m3u8 DbVisualizer Documents -.facebook.com log Pictures Templates Videos

    tyw@CosHiM-EMC:~|⇒ rm -rf "-.facebook.com"
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    Try 'rm --help' for more information.
    tyw@CosHiM-EMC:~|⇒ rm -rf "-.facebook.com"
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    Try 'rm --help' for more information.

    tyw@CosHiM-EMC:~|⇒ rm -rf "\-.facebook.com"

    tyw@CosHiM-EMC:~|⇒ ls
    17.m3u8 DbVisualizer Documents -.facebook.com log Pictures Templates Videos

    tyw@CosHiM-EMC:~|⇒ rm -.facebook.com
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    Try 'rm --help' for more information.
    tyw@CosHiM-EMC:~|⇒ rm \-.facebook.com
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    Try 'rm --help' for more information.

    tyw@CosHiM-EMC:~|⇒ rm \-\.facebook.com
    rm: invalid option -- '.'
    Try 'rm ./-.facebook.com' to remove the file ‘-.facebook.com’.
    32 条回复    2015-03-04 07:26:07 +08:00
    iptux
        1
    iptux  
       2015-03-03 01:24:14 +08:00 via iPhone   ❤️ 2
    rm -- filename
    sNullp
        2
    sNullp  
       2015-03-03 01:35:32 +08:00   ❤️ 3
    除了 1 楼的,它自己告诉你的 “rm ./-.facebook.com” 也可以啊。。
    tywtyw2002
        3
    tywtyw2002  
    OP
       2015-03-03 01:36:49 +08:00
    @sNullp 好吧,智商低了一回。。。。。
    hjc4869
        4
    hjc4869  
       2015-03-03 02:07:38 +08:00 via iPhone   ❤️ 14
    我感觉rm绝望地不停提醒楼主正确的做法但是。。楼主就是视而不见……
    falcon05
        5
    falcon05  
       2015-03-03 02:36:38 +08:00 via iPhone
    呵呵,楼主好任性
    @hjc4869
    msg7086
        6
    msg7086  
       2015-03-03 04:10:41 +08:00 via iPhone   ❤️ 1
    rm: 怪我咯?
    Tiande
        7
    Tiande  
       2015-03-03 09:36:15 +08:00 via iPhone
    笑shi了,这画面经典到哭啊
    Tiande
        8
    Tiande  
       2015-03-03 09:37:52 +08:00 via iPhone
    hhh,之前删 /home 的,也是您啊。
    rm: 怪我咯?
    jybox
        9
    jybox  
       2015-03-03 10:02:32 +08:00
    加引号 ...
    lerry
        10
    lerry  
       2015-03-03 10:06:13 +08:00
    楼主可以换一个更强大的Shell程序,比如zsh,输入rm 按 tab 会依次选中当前目录下的文件,就可以删除了
    dotpig
        11
    dotpig  
       2015-03-03 10:07:04 +08:00
    rm 彻底被楼主整哭了~
    zealic
        12
    zealic  
       2015-03-03 10:49:27 +08:00   ❤️ 1
    绝望的 rm ,23333
    club
        13
    club  
       2015-03-03 11:33:20 +08:00
    可憐的'rm'233333
    hellov22ex
        14
    hellov22ex  
       2015-03-03 11:38:11 +08:00
    不知道为什么,画面感太强了 233333
    caomu
        15
    caomu  
       2015-03-03 11:56:05 +08:00 via Android
    rm恨不得穿屏幕而出夺过lz键盘。。。
    tuoxie007
        16
    tuoxie007  
       2015-03-03 12:32:51 +08:00
    用python质量的编程语言写代码删试试
    tuoxie007
        17
    tuoxie007  
       2015-03-03 12:34:04 +08:00
    用python之类的编程语言写代码删试试,打错字抱歉
    lzk800
        18
    lzk800  
       2015-03-03 12:38:53 +08:00
    @tywtyw2002 你需要补充知识点:inode
    dbg
        19
    dbg  
       2015-03-03 14:17:10 +08:00
    rm ./-.facebook.com
    即可
    shiny
        20
    shiny  
       2015-03-03 14:18:47 +08:00
    我仿佛听见 rm 在呐喊:愚蠢的人类!!!!11
    isnetit
        21
    isnetit  
       2015-03-03 15:52:01 +08:00
    http://www.dwheeler.com/essays/filenames-in-shell.html

    Filenames and Pathnames in Shell: How to do it Correctly
    yangxiongwei
        22
    yangxiongwei  
       2015-03-03 15:58:25 +08:00
    rm已经绝望了..
    ZHenJ
        23
    ZHenJ  
       2015-03-03 16:42:13 +08:00
    好萌~~
    Tink
        24
    Tink  
       2015-03-03 16:51:11 +08:00
    为啥不加引号呢
    tywtyw2002
        25
    tywtyw2002  
    OP
       2015-03-03 16:54:10 +08:00 via iPhone
    @lerry zsh补全不行。 对-无效。
    lxrmido
        26
    lxrmido  
       2015-03-03 16:57:48 +08:00
    我没忍住,在办公室笑出声来了……
    别拦我,今年我就靠这篇主题看破灰暗的人生了
    huasha
        27
    huasha  
       2015-03-03 20:44:05 +08:00 via Android
    先收藏了,没事儿的时候就翻出来看看
    poplarch
        28
    poplarch  
       2015-03-03 22:17:07 +08:00
    $ touch -- -.facebook.com
    $ ls -i
    33714211 -.facebook.com
    $ find . -inum 33714211 -exec rm {} +
    $ ls

    找到inode就好删掉了
    frankzeng
        29
    frankzeng  
       2015-03-03 22:54:12 +08:00
    不断提示try怎么怎么样,楼主视而不见,难道不看提示的?
    efi
        30
    efi  
       2015-03-04 01:22:01 +08:00
    tyw@CosHiM-EMC:~|⇒ rm \-\.facebook.com
    rm: invalid option -- '.'
    rm: You are a fucking idiot. Try 'rm --preserve-root /' to remove the file ‘-.facebook.com’.
    silvernoo
        31
    silvernoo  
       2015-03-04 07:09:11 +08:00
    rm *facebook.com 这样?
    endoffight
        32
    endoffight  
       2015-03-04 07:26:07 +08:00 via Android
    很简单,将特殊符号转义即可
    mac下好多文件夹有空格,也是这样处理的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1035 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:12 · PVG 03:12 · LAX 12:12 · JFK 15:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.