I created a phantom file now i can't delete it?

Ok, somehow i've managed to create two .ksh files with the same name. Impossible i know but somehow i did it by mistake...

I was actually copying a file and renaming it as something else but as i was typing the copy name i hit the delete key by mistake and got the ^? characters in the file name and hit return by force of habit... e.g. test^?.ksh
When i did an 'ls -lrt' the file just shows up as "test.ksh"

I created another file with same name thinking it would overwrite it but no it created the file and it now when i now do an 'ls -lrt' i have the two .ksh scripts show up.

But if i do an 'ls-lrt test*.ksh it will only show up the good file that i created.

I'm not all that familiar with unix/aix and have no idea what i've done.

Can anyone give me some pointers on how to get rid of this phantom file i created...

Thanks,
Jaz

Hi, you can try "ls -li" thus finding the Inode number.

Hi,

It's showing the inode number as 591...

Take a look here - http://tldp.org/LDP/abs/html/moreadv.html
and especially Example 15-4.
Hope this helps.

I think your best bet is to copy the file again to another name entirely, then do rm tes*.ksh. I expect that will work.

cp test.ksh saved_test.ksh
rm tes*.ksh

Another option is to check your manpage for the "remove with confirmation" option for rm. In solaris it's -i, not sure if it's the same for aix. Then do rm -i * (of course do the correct switch if yours isn't -i) and respond "n" to all the files except the bad one, say "y" to that.

I tried that but it didn't find the test.ksh... It shows up when i list the directory but if i try to cp, rm, cat, etc the file it doesn't see it...

Then you may have to go with the rm -i * idea. Just be very careful to say no to all the files except for the exact one you want to delete. I believe that will work since the * by itself should fine every file in the directory. Since your bad file shows up when you do ls it should work.

Have you tried rm *?.ksh?

I can't do that... I'm on a production box and don't think deleting all the ksh scripts would go down to well...

I managed to get it deleted in the end up. I have hummingbird exceed installed and was able to log on to the box using the ftp feature... I saw the file there and it was called test.ksh

A round about way but hey it worked....

Thanks for all your help guys...

you can run the following:

ls -li to identify the inode of the offending file so in thi instance lets say the inum is = 3146101

# ls -li test*

3146101 -rw-r--r-- 1 bin bin 9996 Feb 23 15:44 test.ksh

then you can use the find command to remove this:

find . -xdev -inum 3146101 -exec rm {} \;

sorted!