The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Deleting Files With Special Characters (http://hintsforums.macworld.com/showthread.php?t=7020)

baryonyx 11-11-2002 11:19 AM

Deleting Files With Special Characters
 
Has anyone tried to delete a file with a special character--say the tm symbol--in it in Terminal?

Looks to me like it's impossible. I've tried the following and am open to further suggestions:

1) Drag folder into terminal--much multi-line weirdness results;

2) trying to type the symbol in Terminal (option-2)--same problem as above;

3) copy and paste from Finder--no dice;

4) copy and paste from 'ls' listing--no dice.

Anybody have an idea what to do?

Thanks,

Andy

sao 11-11-2002 12:34 PM

baryonyx,

In Apple Doc "Mac OS X: About Trash, Deleting Locked Files" it says:

Quote:

File or volume named with special characters

1. Note the name of the volume which the files are being deleted from. If you are not sure of the item's location, you can verify that by selecting it then choosing Show Info from the File menu. If the name of the volume contains any special ASCII characters, such as a bullet or trademark character, temporarily rename the volume so that it does not contain these characters.

Example: If you cannot delete files from a volume named "·Documents", rename the volume to "Documents". After the Trash is empty, restore the volume's original name as desired.

2. Examine the name of the files or folders you cannot delete. They should not contain a solidus ("slash", "/") character or any other special ASCII character such as a trademark, quotation mark, or copyright symbol. If the file does, remove the special character or slash from its name.

Example: If you cannot delete a file named "Thoughts/Stuff·", then rename the file to "Thoughts Stuff".

Note: In most cases Mac OS X can delete files whose names contain special characters.
http://docs.info.apple.com/article.html?artnum=106272

Hope this helps.


Cheers...

mervTormel 11-11-2002 12:35 PM

hmm, i wonder if it would help to set your character set encoding to unicode in the terminal prefs ->window settings... ( display )

i have few problems in bash with rm'ing a file named atm™ ; you mention a directory. are you using the proper form of rm? rm -r or rm -d ?
Code:

$ touch atm

$ # OZ: finder rename atm to atm(tm)

$ ll atm™  # tab-completion here

-rw-------    1 merv    staff    0 Nov 11 09:24 atm™

$ rm !*

$ rm atm™

NB: i couldn't complete if there was another filename beginning with at

baryonyx 11-11-2002 01:32 PM

Oh, holy heck, I wasn't clear at all what I was doing. You're supposed to read my mind, after all! :)

Here's more of the story: I'm deleting this file from an OS 9 volume--I'm trying to rid myself of Netscape Communicater™ but for some reason I can't rename the folder in the Finder. It does not seem to matter that I gave myself permission(s) to do so. Rather than simply boot into OS 9 and trash this bad boy I was looking for an "easier" solution--har har!

But this kind of stuff is challenging and interesting, so what the heck.

Merv, I am using rm -r but I get nothing but hiccups because I can't type the filename correctly. The option-2 keyboard command seems to be a command in terminal analogous to 'ls,' which is unfortunate because that's also the keyboard command for (tm)™. How did you get Terminal to use this character?

Andy

Mikey-San 11-11-2002 01:43 PM

What about the tab key?

I just put an option-2 (tm) character in a file on my Desktop, and using the tab key to autocomplete the file name, had no trouble rm'ing the little bugger.


-/-

baryonyx 11-11-2002 01:46 PM

Checked my window settings in Terminal and it turns out I already have character settings to Unicode. Tried Mac (western) and I get nothing at all when typing option-2. Copying the filename over completely ignores the ™ character, so I get the usual "no such file or directory" error when I do a rm -r.

Weird.

Andy

baryonyx 11-11-2002 01:49 PM

mikey-san, I am unclear on your meaning. Are saying that using the Tab key will autocomplete a file or folder name? I tried it and it didn't seem to work...

Can you be specific about the mechanics of this?

Thanks,

Andy

mervTormel 11-11-2002 01:58 PM

Quote:

Originally posted by baryonyx
mikey-san, I am unclear on your meaning. Are saying that using the Tab key will autocomplete a file or folder name? I tried it and it didn't seem to work...
hmm, i alluded to that in my post, but perhaps your missed it?

what happens if you use the shell's tab key to auto-complete the dir name?

% rm -r /Volume/volname/pathto/Netscape[tab]

if you were to post some of your multi-line wierdness from before, it might be interesting, too.

baryonyx 11-11-2002 02:07 PM

Boy, that Tab-complete trick simply does not work for me. I even tried trashing my com.apple.Terminal.plist file and tried it and still no go.

Here's what happens when I drag the folder ito a Terminal window. I get the same thing when copying and pasting:
Code:

[g4:~] dad% sudo rm -r /Volumes/R-2/Applications\ \(Mac\ OS\ 9\)/Netscape\ Communicator
[g4:~] dad% sudo rm -r /Volumes/R-2/Applications\ \(Mac\ OS\ 9\)/Netscape\ \ FolderCommunicator

Note that I'd already typed the 'rm -r' command in prior to dragging. Check out what happens at the end of the path...weird, huh? The double line just happens.

Andy

mervTormel 11-11-2002 02:20 PM

try it from bash:

% bash

$ rm -r /blah/blah/netscape[tab]

$ exit


or try this notation:

% rm -r /blah/blah/Netscape\ Communicator\342\204\242\ Folder


hmm, could your autocomplete be bork'd ? or could there be another 'special' char in there?

baryonyx 11-11-2002 02:41 PM

Argghh. Neither works. I had tried using the \342\204\242\ code before and tcsh didn't like it. Bash didn't think much of it either.

As for my autocomplete, it seems to work fine for Darwin commands. But file names--that's a new one on me--simpy doesn't work.

Quite a problem, isn't this? :)

Andy

baryonyx 11-11-2002 02:55 PM

Report: I just came close. Seems like the ASCII non-lossy encoding will accept a copy and paste of the ™ character--sometimes. The problem with this encoding is that I can't seem to do anything else with it--lots of garbage characters depending on what key one presses. Gave me hope for a minute there.

Andy

mervTormel 11-11-2002 02:57 PM

try setting [x] ignore ownership on this volume in the finder get info window

or, make sure you have rw access to all the dirs in the hierarchy to the netscape dir

then, maybe, you can rename the folder

baryonyx 11-11-2002 03:03 PM

merv, you are a bloody genius. Worked like a charm. Thank you.

Andy

occjph 11-13-2002 09:26 AM

You can delete a file with strange characters (especially hidden characters) by it's inode number.

To find the inode number of a file, list the directory with the -i option:

john# ls -i
2064227 test

2064227 is the inode (serial) number of the file 'test'. Use the find command to delete the file by it's inode number:

find . -inum 2064227 -exec rm {} \;

baryonyx 11-13-2002 09:38 AM

Have you submitted this as a tip to Rob's main page? I think you ought to--very tasty little tidbit.

Englabenny 04-07-2003 03:19 PM

twin
 
similar thread:
http://forums.macosxhints.com/showth...3610#post53610

rmanke 03-27-2007 06:09 PM

I get an error when I try this, saying "File not found" with the file named "Ti?ng Viê?t.html"

I can't access this file any way possible.

Any ideas how I can trash this file?


Quote:

Originally Posted by occjph (Post 34404)
You can delete a file with strange characters (especially hidden characters) by it's inode number.

To find the inode number of a file, list the directory with the -i option:

john# ls -i
2064227 test

2064227 is the inode (serial) number of the file 'test'. Use the find command to delete the file by it's inode number:

find . -inum 2064227 -exec rm {} \;


rmanke 03-27-2007 06:11 PM

Quote:

Originally Posted by rmanke (Post 368404)
I get an error when I try this, saying "File not found" with the file named "Ti?ng Viê?t.html"

I can't access this file any way possible.

Any ideas how I can trash this file?

By the way, the file name I listed here isn't showing up properly on this page, the "Tieng Viet" has a couple accents over each of the e's.

hayne 03-27-2007 06:14 PM

Quote:

Originally Posted by rmanke (Post 368404)
I get an error when I try this, saying "File not found" with the file named "Ti?ng Viê?t.html"

I can't access this file any way possible.

Any ideas how I can trash this file?

The solution to this specific problem is in this older thread:
http://forums.macosxhints.com/showthread.php?t=62165

rmanke 03-27-2007 06:33 PM

Quote:

Originally Posted by hayne (Post 368408)
The solution to this specific problem is in this older thread:
http://forums.macosxhints.com/showthread.php?t=62165

Thank you for the suggestion!

Ron


All times are GMT -5. The time now is 10:33 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.