tywtyw2002
V2EX  ›  问与答

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

  •  
  •   tywtyw2002 · Mar 3, 2015 · 7018 views
    This topic created in 4114 days ago, the information mentioned may be changed or developed.
    文件名是这样的 `-.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 replies    2015-03-04 07:26:07 +08:00
    iptux
        1
    iptux  
       Mar 3, 2015 via iPhone   ❤️ 2
    rm -- filename
    sNullp
        2
    sNullp  
       Mar 3, 2015   ❤️ 3
    除了 1 楼的,它自己告诉你的 “rm ./-.facebook.com” 也可以啊。。
    tywtyw2002
        3
    tywtyw2002  
    OP
       Mar 3, 2015
    @sNullp 好吧,智商低了一回。。。。。
    hjc4869
        4
    hjc4869  
       Mar 3, 2015 via iPhone   ❤️ 14
    我感觉rm绝望地不停提醒楼主正确的做法但是。。楼主就是视而不见……
    GG668v26Fd55CP5W
        5
    GG668v26Fd55CP5W  
       Mar 3, 2015 via iPhone
    呵呵,楼主好任性
    @hjc4869
    msg7086
        6
    msg7086  
       Mar 3, 2015 via iPhone   ❤️ 1
    rm: 怪我咯?
    Tiande
        7
    Tiande  
    PRO
       Mar 3, 2015 via iPhone
    笑shi了,这画面经典到哭啊
    Tiande
        8
    Tiande  
    PRO
       Mar 3, 2015 via iPhone
    hhh,之前删 /home 的,也是您啊。
    rm: 怪我咯?
    jybox
        9
    jybox  
       Mar 3, 2015
    加引号 ...
    lerry
        10
    lerry  
       Mar 3, 2015
    楼主可以换一个更强大的Shell程序,比如zsh,输入rm 按 tab 会依次选中当前目录下的文件,就可以删除了
    dotpig
        11
    dotpig  
       Mar 3, 2015
    rm 彻底被楼主整哭了~
    zealic
        12
    zealic  
       Mar 3, 2015   ❤️ 1
    绝望的 rm ,23333
    club
        13
    club  
       Mar 3, 2015
    可憐的'rm'233333
    hellov22ex
        14
    hellov22ex  
       Mar 3, 2015
    不知道为什么,画面感太强了 233333
    caomu
        15
    caomu  
       Mar 3, 2015 via Android
    rm恨不得穿屏幕而出夺过lz键盘。。。
    tuoxie007
        16
    tuoxie007  
       Mar 3, 2015
    用python质量的编程语言写代码删试试
    tuoxie007
        17
    tuoxie007  
       Mar 3, 2015
    用python之类的编程语言写代码删试试,打错字抱歉
    lzk800
        18
    lzk800  
       Mar 3, 2015
    @tywtyw2002 你需要补充知识点:inode
    dbg
        19
    dbg  
       Mar 3, 2015
    rm ./-.facebook.com
    即可
    shiny
        20
    shiny  
    PRO
       Mar 3, 2015
    我仿佛听见 rm 在呐喊:愚蠢的人类!!!!11
    isnetit
        21
    isnetit  
       Mar 3, 2015
    http://www.dwheeler.com/essays/filenames-in-shell.html

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

    找到inode就好删掉了
    frankzeng
        29
    frankzeng  
       Mar 3, 2015
    不断提示try怎么怎么样,楼主视而不见,难道不看提示的?
    efi
        30
    efi  
       Mar 4, 2015
    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  
       Mar 4, 2015
    rm *facebook.com 这样?
    endoffight
        32
    endoffight  
       Mar 4, 2015 via Android
    很简单,将特殊符号转义即可
    mac下好多文件夹有空格,也是这样处理的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 122ms · UTC 03:43 · PVG 11:43 · LAX 20:43 · JFK 23:43
    ♥ Do have faith in what you're doing.