October 16, 2006
Just ran into an issue with a file named '-t6' on an AIX system. (No, I didn't put it there.)

After taking a few stabs at deleting it unsuccessfully, a quick google search showed the solution. I thought it was pretty cool so I thought I would share it:

How do you delete a file called "-xx"? You can of course use a graphical file manager and select the file graphically but how do you delete it with the rm command?

rm will normally interpret the -xx as an option because it starts with a minus sign. There are two ways to avoid that:

  1. Make sure the file name does not start with a minus: For files this is always possible. You can e.g use the full absolute path to the file. (e.g rm /tmp/-xx assuming that the file -xx is in /tmp)
    You can also write -xx as ./-xx :
    rm ./-xx
  2. Most unix commands accept a double minus (--) to indicate that this is the end of the options list.
    rm -- -xx
    will therefore tell rm that -xx is a file and not an option.
Categories
Archives
March 2010
S M T W T F S
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Complete Archives

Tools
Search:
  Advanced Search

Mailing List:



Currently Reading
Recently Read
Animal Farm

Animal Farm
George Orwell

Life of Pi

Life of Pi
Yann Martel

The Fourth K

The Fourth K
Mario Puzo

Catch 22

Catch 22
Joseph Heller

the Sicilian

the Sicilian
Mario Puzo

The Quantum Rose

The Quantum Rose
Catherine Asaro

Members
Sponsors
Blogroll
Links
Stats
Entries: 2147
Comments: 2925
Trackbacks: 665
Members: 258

Most Recent:
  Entry: 11/09/08 9:38
  Comment: 11/17/08 12:27
  Visitor: 03/20/10 3:48

Powered by:
  ExpressionEngine

Extreme Tracking