Can't delete a file in the trash on OSX 10.11.6

I use a Mac running OSX El Capitan = UNIX user the hood. After rearranging files on an external hard drive, I ended up with a folder in the trash containing a file called "~INITPicker 2.0". I cannot empty the trash, and so delete the file. I even tried terminal, using the rm file command and recursively remove folder command, all to no avail. I cannot re-name the offending file, as it tells me I can't. I think the problem is with the tilde in the name. Can any clever soul tell me how to delete this file using terminal (the Mac's command line utility)?

Any guidance gratefully received.

Did you reboot your Mac and tried again?

Yes, I re-booted. Still no luck.

Try the terminal solution again and put the filename in quotation marks:

rm "~INITPicker 2.0"

hth,
DN2

DukeNuke2, first of all, many thanks for taking the time to respond to my squawk.

Here's a record of my trial:

in the trash, folder xx, inside that folder ee, inside that ~InitPicker 2.0.

djCUDA:.Trash macuser$ cd ~/.Trash/xx/ee/
djCUDA:ee macuser$ rm "~INITPicker 2.0"
rm: ~INITPicker 2.0: No such file or directory
djCUDA:ee macuser$ ls
INITPicker 2.0
djCUDA:ee macuser$ 

I should have added that when I try to empty the trash via the Mac menu, I get the following errors:

unexpected error occurred -50   /*error in user parameter list*/
xx is in use
ee is in use

Just noticed that the first character in the offending file is not a tilde, but NUL.

Can this help diagnosis? How do I type a NUL?

ADDENDUM after copy and paste from ls

djCUDA:ee macuser$ rm "INITPicker 2.0"
rm: INITPicker 2.0: Invalid argument
djCUDA:ee macuser$ 

Hi,

Read this thread:

File name starts with esc character.

I'm not a OSX expert but, as with generic Unix/Linux, if all else fails, nuke the inode. The inode is the only route that the OS can find the file. If the inode doesn't exist, neither does the file.

Read Corona688's post#2.

If Corona688 is on here today with luck he may well chip in.

---------- Post updated at 07:29 PM ---------- Previous update was at 07:16 PM ----------

And don't forget you can have the same inode number on different filesystems. So make absolutely sure which filesystem you are operating on.

sent from my HTC smartphone

2 Likes

Did you try booting into Safe Mode (hold shift key down during bootup)?

I did try safe boot, to no avail. Thanks.

---------- Post updated at 03:45 PM ---------- Previous update was at 03:40 PM ----------

[quote=hicksd8;302988007]
Hi,

Thanks for the info. I tried and failed, as you see here:

djCUDA:ee macuser$ ls -li
total 0
3774747 -rwxr-xr-x@ 1 macuser  staff  0 26 Nov  1991 INITPicker 2.0
djCUDA:ee macuser$ find . -inum 3774747 -exec echo rm '{}' ';'
rm ./INITPicker 2.0
djCUDA:ee macuser$ ls
INITPicker 2.0
djCUDA:ee macuser$ find . -inum 3774747 -exec rm '{}' ';'
rm: ./INITPicker 2.0: Invalid argument

No wonder I drink too much.... It seems that the initial NUL character is the problem?

Hi,

Can you try the command with the format;

djCUDA:ee macuser$ find . -inum 3774747 -exec rm {} \;

Regards

Gull04

Gull,

Thanks for your suggestion. See the result:

djCUDA:ee macuser$ find . -inum 3774747 -exec rm {} \;
rm: ./INITPicker 2.0: Invalid argument

Once again, it seems UNIX doesn't like the NUL at the beginning of the filename. If there's some way to delete that character, I think your code would work.

regards, David

What about the proposals in the link suggested by hicksd8 in post#6?

RudiC, I did try the node suggestion, but again it did not work.

I got:

djCUDA:ee macuser$ find . -inum 3774747 -exec rm {} \;
rm: ./INITPicker 2.0: Invalid argument

That stubborn NUL is still fighting back.

And the other suggestions?

What about trying to delete it with the find command directly:

find . -maxdepth 1 -type f -inum 3774747 -delete

DukeNuke2,

Again, no luck:

djCUDA:ee macuser$ find . -maxdepth 1 -type f -inum 3774747 -delete
find: -delete: unlink(./INITPicker 2.0): Invalid argument

I know essentially nothing about UNIX, but surely I'm not the first person to run into this problem of a NUL in the filename?

I appreciate members taking the time to post suggestions! regards, David

The name of a file is a null-terminated string, so it is normally impossible to create a file with a name containing a null character. Please change directory to the directory containing the file you can't remove and then show us the output you get from the command:

ls *T* | od -bc

Hi,

I'm hopefull that you've already tried the empty trash from the GUI and that that just failed to remove the file, what I would also suggest is that you try and rename the file within the GUI and then delete it.

I have seen something similar to this on my Macbook, but can't remember whether I deleted it from the CLI or the GUI.

As a last option, you could also check out the stuff here at the Apple Support page.

Regards

Gull04

Another trick that I have used on Unix with great care is:

 
 # cd <directory of oddly named file>
 # rm -i *
  

which will offer you every file in the directory for a Y/N for deletion. You can then say 'N' for all but the file that you want rid of where you say 'Y'. However, it's not much good on a directory with thousands of files in it and you must double check you location and everything before you use it.

I've just checked the OSX man page repository on this forum and 'rm' in OSX does support then '-i' switch.

I created a file with the same name as the OP and tried to delete it with every trick in the book. No luck! The problem is the "NUL" character at the begining which is a 3 byte character and nothing seems to work for that. I found a website which claims that this is a Mac OS 10.11.X only problem. Now I'm also stuck with that file... But in the next few days I will do a complete new install of 10.12.X and so I'm not concerned much, yet! :smiley:

But I'm glad if someone is able to find a solution!

2 Likes

Does OSX support specification of a character in the form ^000 to represent NUL?

---------- Post updated at 12:12 PM ---------- Previous update was at 12:03 PM ----------

@DN2......since you are going to rebuild the system anyway, does OSX support 'clri' command? If so, what happens if you nuke the inode completely using that?

Yes, know that in such circumstances the blocks of the cleared file will show up as 'missing' on a fsck.

Repeat, I'm not an OSX user so I'm just talking generic Unix/Linux here but I've nuked many an inode (with success) to clear a file and then run fsck afterwards to clean up.

Everyone except DN2 please ignore this post. It's dangerous!