Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

How to remove a file with a leading dash '-' in it's name?

UNIX for Advanced & Expert Users


Tags
cpio

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-02-2003
GSalisbury GSalisbury is offline
Registered User
 
Join Date: Apr 2002
Last Activity: 25 February 2015, 12:48 PM EST
Location: New Jersey
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
How to remove a file with a leading dash '-' in it's name?

Somehow someone created a file named '-ov' in the root directory.

Given the name, the how was probably the result of some cpio command they bozo'ed.

I've tried a number of different ways to get rid of it using * and ? wildcards, '\' escape patterns etc.. They all fail with " illegal option -- o or v" errors. It appears that the '-' dash is being treated as options to my rm command.

If the p.o.s. file was in most any other directory I'd just move everything else out to somewhere then blow away the directory and re-make it and begin the stuff back.

Can't really do that with the root directory <g>.

Anyone have any other ideas on how it can be make to go away?

System is an Esix System V Release 4 box but I don't think that matters.

Thanks.

Geo.
Sponsored Links
    #2  
Old Unix and Linux 05-02-2003
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 27 April 2015, 10:26 AM EDT
Location: Ashburn, Virginia
Posts: 9,931
Thanks: 64
Thanked 447 Times in 264 Posts
Use the full pathname

rm /-ov
Sponsored Links
    #3  
Old Unix and Linux 05-02-2003
dangral dangral is offline Forum Advisor  
Registered User
 
Join Date: Oct 2002
Last Activity: 31 July 2013, 6:52 PM EDT
Posts: 723
Thanks: 3
Thanked 4 Times in 4 Posts
you can also do this:

rm -- -ov

The -- after rm tells it to stop looking for options.
The Following User Says Thank You to dangral For This Useful Post:
blutgens (09-28-2012)
    #4  
Old Unix and Linux 05-05-2003
GSalisbury GSalisbury is offline
Registered User
 
Join Date: Apr 2002
Last Activity: 25 February 2015, 12:48 PM EST
Location: New Jersey
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks.
I used the rm /-ov.
I feel stupid (guess i am)<g>.
I just never tried the obvious.
G.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove leading zeroes in 2nd field using sed pchang Shell Programming and Scripting 18 10-04-2010 05:13 PM
How to concatenate string containing a leading dash? wolfv Shell Programming and Scripting 5 12-05-2009 04:50 PM
Not able to remove leading spaces panyam Shell Programming and Scripting 5 05-28-2009 05:14 AM
remove dash melanie_pfefer Shell Programming and Scripting 1 01-26-2009 05:05 AM
sed over writes my original file (using sed to remove leading spaces) laser Shell Programming and Scripting 6 12-02-2008 09:48 AM



All times are GMT -4. The time now is 04:22 PM.