Solved

filenames that begin with "-"

Posted on 2001-08-23
8
299 Views
Last Modified: 2010-04-21
here's a dumb question:

I have a filename that begins with a "-", like "-xyz".
I can see it with ls -la

However, I can't figure out how to remove it.
Every tool like "rm", "mv", interpret the - as a command line argument and error out.

I've tried:

rm -xyz
rm "-xyz"
rm '-xyz'
rm ?xyz
rm *xyz
rm \-xyz
rm "\-xyz"

nothing works.  My shell is tcsh if that matters.
0
Comment
Question by:red5
  • 4
  • 4
8 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6420380

Is it in a directory with alot of files in it?If not you can try rm -ir and say no to all files except that one.
0
 

Author Comment

by:red5
ID: 6420391
there are a lot of files.

there must be a better way.

(I was able to delete it using ftp, but that was hack - I'm just curious now...)
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6420395

I think rm -f -xyz might do it.
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 50 total points
ID: 6420398
no,
actually you have to hide the file name from the command

rm ./-xyz
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:red5
ID: 6420400
there are a lot of files.

there must be a better way.

(I was able to delete it using ftp, but that was hack - I'm just curious now...)
0
 

Author Comment

by:red5
ID: 6420403
ya, that's it.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6420412
red5
did you try  this ? It will remove the file

 rm ./-xyz      
0
 

Author Comment

by:red5
ID: 6420415
ya, sorry, I had a double submit on accident...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now