System Administration

Re: weird file - can't be deleted....

 
SOLVED
Go to solution
Christina Martin
Frequent Advisor

weird file - can't be deleted....

-rw-rw-r-- 2 root AJP 92 Sep 1 00:00 ---
-rw-rw-rw- 2 root AJP 648605 Sep 7 01:00 35010000.07
-rw-rw-rw- 2 root AJP 8792777 Sep 10 01:04 35010000.10
-rw-rw-rw- 2 root AJP 11055850 Aug 29 01:04 35010000.29

The first 2 lines show --- as the file name.
when I do a ls -lab it still shows --- as the file name.

I tried an rm -i * to remove the file, I get illegal option.

I tried redirecting the directory list to a file and creating a shell to remove the file, same result, illegal option.

Does anyone have any idea how to remove this file without having to copy the required information into another directory and deleting the entire directory that this resides in? (Not even sure if that would work).

Thanks
Lisa Taylor
14 REPLIES 14
Alan Meyer_4
Respected Contributor

Re: weird file - can't be deleted....

do an ls -i to display the inode of the file.

Then do a find . -inum n -exec rm {} \; to remove the file.
" I may not be certified, but I am certifiable... "
James R. Ferguson
Acclaimed Contributor

Re: weird file - can't be deleted....

Hi:

The easy way to remove a file named "--" is to tell 'rm' that the hypehen is NOT one of its options:

# rm -i - --

Note the "-" says that there are no more options (flags) on the commandline.

Regards!

...JRF...
TwoProc
Honored Contributor
Solution

Re: weird file - can't be deleted....

This one works pretty well to get your "rm -i" command to work:

rm -i - ./*

But, unless the list of files in the current directory is short - the approach using the inode number (first reply posting) is the one I like best for very tricky items.
We are the people our parents warned us about --Jimmy Buffett
Mei Jiao
Respected Contributor

Re: weird file - can't be deleted....

Hi Lisa,

I also find that if you specify the path (either full path of relative path) with double quotes "", it'll work:

# rm "/
Hope it helps too.

Best regards,
Mei
Vibhor Kumar Agarwal
Esteemed Contributor

Re: weird file - can't be deleted....

Try this option also:

ls -l | awk '{ if (NR==1) print rm $NF }' | sh
Vibhor Kumar Agarwal
Adisuria Wangsadinata_1
Honored Contributor

Re: weird file - can't be deleted....

Hi Lisa,

Check this document below (docID : KBRC00000429) about 'Remove File with Special Character in the Name' :

http://www2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000080078334

Hope this info can help you to resolve the problem.

Cheers,
AW
now working, next not working ... that's unix
Matthew_50
Valued Contributor

Re: weird file - can't be deleted....

# remove it using following.
rm -- ---

The key part is the file name,
which is leading with "-".
The "-" character is collision with
unix command option "-".
we can use "--" to void the options.
Marcel Boogert_1
Trusted Contributor

Re: weird file - can't be deleted....

Hi,

You can also use an FTP program to handle your deletion request.

If you've got a MSWin client you can us wsftp or something to delete the file.

It works pretty good and the FTP program handles the special characters.


Regards, MB.
Muthukumar_5
Honored Contributor

Re: weird file - can't be deleted....

Simply as,

rm -f ./---

or

rm -f /---

or

rm -- ---

where -- used to show that getopts() argument to ls binary is completed.

hth.
Easy to suggest when don't know about the problem!