Results 1 to 7 of 7

Thread: Remove -13 directory

  1. #1

    Default Remove -13 directory

    Dear all,
    today I was using some program and accidentaly I have created a directory called (name inside brackets)

    "-13"

    When I try to remove this empty dir I get

    rmdir -13
    rmdir: invalid option -- '1'

    what can I try to remove it?

    B.R
    Alex

  2. #2
    Join Date
    Jun 2008
    Location
    The English Lake District. UK - GMT/BST
    Posts
    36,729
    Blog Entries
    20

    Default Re: Remove -13 directory

    rename it, then delete it

    Code:
    mv -13 plonk
    Code:
    rmdir plonk
    Leap 15.1_KDE
    My Articles Was I any help? If yes: Click the star below

  3. #3
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Remove -13 directory

    rmdir ./-13

  4. #4
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Remove -13 directory

    On 2011-11-08 20:46, alaios wrote:

    > When I try to remove this empty dir I get
    >
    > rmdir -13
    > rmdir: invalid option -- '1'
    >
    > what can I try to remove it?


    Try "rmdir \-13"

    If not, try using mc.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 11.4 x86_64 "Celadon" at Telcontar)

  5. #5
    Join Date
    Jun 2008
    Location
    Earth - Denmark
    Posts
    10,730

    Default Re: Remove -13 directory

    On 11/08/2011 08:46 PM, alaios wrote:
    >
    > what can I try to remove it?


    try
    ls ?13

    if you see ONLY -13 listed (and . & ..) then try

    rm -ir ?13

    --
    DD
    http://tinyurl.com/DD-Caveat
    openSUSE®, the "German Automobiles" of operating systems

  6. #6
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,502
    Blog Entries
    3

    Default Re: Remove -13 directory

    The suggestion by ken_yap (post #3) should work. I'm skeptical of the others. His suggestion was:
    rmdir ./-13

    That solves the problem by using a name for the file that does not begin with "-".

    Some of the other suggestions use quoting, or a wildcard. The quoting and/or wildcard tell the shell how to handle the "-". But the shell will still pass that on the the target command (the "rmdir" command). The error message is coming from the target command, rather than the shell. So it is what the target command sees that matter.

    rmdir ./-13

    a test shows that:

    rmdir -- -13

    would also work. I think that's part of the gnu way of doing things - a "--" terminates the command options and anything following that is a regular parameter (e.g. filename) rather than an option.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  7. #7
    Join Date
    Jun 2008
    Location
    Earth - Denmark
    Posts
    10,730

    Default Re: Remove -13 directory

    On 11/09/2011 04:16 PM, nrickert wrote:
    > I'm skeptical of the others.


    me too...now that i tried it and see that bash is smart enough to tell
    you what to use (and where to look to find what to use)


    --
    DD
    http://tinyurl.com/DD-Caveat
    openSUSE®, the "German Automobiles" of operating systems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •