Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to delete a file called -1 4

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
0
0
GB
I have a file called -1 - don't know ho it got into my filesystem but it did !

I have tried to rename the file then remove it to no success, you also cannot perform a more on the file either.
 
You probably have escape characters in the filename. Go to the directory where the file is, then do a rm -i *. This will INTERACTIVELY PROMPT for removing each file in that directory. Only answer "y" to the -1 fil1 and "n" to all others. Once you have answered "y" to the -1 file, you can break out with ctrl-c.

crowe
 
Tried that but unfortunately the message:

rm: Not a recognized flag: 1
Usage: rm [-firRe] [--] File...

Is displayed which is the same as when trying to do rm -1
 
Did you enter 1 or i as suggested by Crowe? The -i option should work fine.
 
To let rm know that -1 is a file name and not an option you should use
rm -- -1
where -- is a delimiter that indicates the end of the flags.

Hilarity.
 
Hi everyone thanks for your help - I used the rm -- -1 and it deleted the file for me. Thanks again.

Max
 
The other way to overcome this sort of problem (especially if you have a file called '*') is to use find...

Firstly ascertain the inode number of the file...

ls -i

... then plug the inode number into the following find command...

find . -inum inode_number -exec {} \; -print

...obviously substituting inode_number with the actual inode.

Hope it helps.
Dave Vickers.
 
now *that* is cool Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top