Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > removing a garbled file name.

removing a garbled file name.
Thread Tools
Forum Regular
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 28, 2006, 07:37 PM
 
I was careless in vi resulting in a file named –1. How can I remove it?
     
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status: Offline
Reply With Quote
Oct 28, 2006, 10:26 PM
 
Use the rm command.

You can use tab completion to enter the filename… just type the first character(s) of the filename then hit the tab key. If multiple files match, you will have to enter more characters; a second tab will get you a list of all filenames which match the pattern.
     
Forum Regular
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 28, 2006, 10:43 PM
 
Therein lies the problem. I have been trying rm, but it doesn't like the - (minus sign) in front of the 1. I don't remember creating the file but it must have happened while my fat thumb was using vi.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Oct 29, 2006, 01:47 AM
 
Put the filename in quotes so rm doesn't think it's a flag.

You could also just use the Finder, I reckon.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Junior Member
Join Date: Nov 2001
Location: Seattle
Status: Offline
Reply With Quote
Oct 29, 2006, 03:10 AM
 
Add the "--" option before the file; this stops rm from processing dashes as arguments. Thus:

rm -- -1
     
Forum Regular
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 29, 2006, 05:46 PM
 
Juggle5,
That did it. Thank you very much.
     
Grizzled Veteran
Join Date: Mar 2004
Status: Offline
Reply With Quote
Oct 31, 2006, 08:00 PM
 
One could also use absolute paths:

rm /full/path/to/the/file/-1

or [probably], any relative path that doesn't start with the '-' :

rm "$PWD/-1"

(to say nothing of renaming the item with Finder )
-HI-
     
Forum Regular
Join Date: Oct 2003
Status: Offline
Reply With Quote
Oct 31, 2006, 10:11 PM
 
Thanks Hal,
I'll make a note of that.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:43 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2