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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete odd-named files (eg. a file called ~!)

Status
Not open for further replies.

itr0754

Technical User
Dec 17, 2002
58
PR
I have a user who accidentally created a file named "~!". How can I delete this file ?? Here's the file description..

-rw-r--r-- 1 iolivera sys 34073 Mar 20 2000 ~!

Thanks for the help !!
 
rm *\!

would delete everything in your current directory that ended with a !
 
bring up the file manager using X.. you can do it that way also.
 
Put ./ in front on the file name. In your case it would be ./~
 
If all else fails this one has worked for me everytime.

Find the inode # of the file.

ls -i

then
find <current dir> -inum <inode #> -exec mv {} asdf \;
I usally rename the file to see if it is needed. Else you could just do <rm {}>.
 
The best way IHMO is:

from within the directory type rm -i *

You will be prompted y/n
 
So, let's say you have 100 files in the directory and one of them is named ~!. The file name ~! is going to be the last file in the directory.

Do you really want to answer 100 questions before you get to the file you want to delete?
 
Questions for you: What is the real name of this file? Does ls -bl show a different name? I can delete ~! from within sh as well as ksh.

For troublesome files, I create a shell script from ls -b. In this case, knowing that the filename is only two characters long, ls -b ?? > rm.sh. I then edit rm.sh by insertinf rm -i in front of each file I want to remove and removing all others. Then, sh ./rm.sh.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top