Find the answer to your Linux question:
Results 1 to 5 of 5
hi all, how to remove a file, which is starting with hyphon "-" ? ex: -file1.txt. iwant to remove this file.. thank in advance....
  1. #1
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6

    removing a file

    hi all,


    how to remove a file, which is starting with hyphon "-" ? ex: -file1.txt. iwant to remove this file..


    thank in advance.

  2. #2
    Just Joined!
    Join Date
    Aug 2009
    Location
    Mumbai, India
    Posts
    75
    Hi,

    Try this: rm -rf ./-file1.txt

    --Syd

  3. #3
    Just Joined!
    Join Date
    Sep 2009
    Posts
    6
    thank u .. its working

  4. #4
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    rm -rf ./-file1.txt
    This assumes you are in the same directory as the file. You can use the full path and it will work as well. You don't really need the recursive and force flags (-rf)for a single file either. I'm wary of using those unless I absolutely need to, since a little mistype means a lot of lost data.

  5. #5
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    You can always use the -- switch:

    Code:
    rm -- -file1.txt
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

Posting Permissions

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