Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
Old 11-11-2002, 11:19 AM   #1
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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
baryonyx is offline   Reply With Quote
Old 11-11-2002, 12:34 PM   #2
sao
Moderator
 
Join Date: Jan 2002
Location: Singapore
Posts: 4,237
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...
sao is offline   Reply With Quote
Old 11-11-2002, 12:35 PM   #3
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
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
__________________
On a clear disk, you can seek forever.
mervTormel is offline   Reply With Quote
Old 11-11-2002, 01:32 PM   #4
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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

Last edited by baryonyx; 11-11-2002 at 01:36 PM.
baryonyx is offline   Reply With Quote
Old 11-11-2002, 01:43 PM   #5
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
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.


-/-
Mikey-San is offline   Reply With Quote
Old 11-11-2002, 01:46 PM   #6
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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 is offline   Reply With Quote
Old 11-11-2002, 01:49 PM   #7
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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
baryonyx is offline   Reply With Quote
Old 11-11-2002, 01:58 PM   #8
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
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.
__________________
On a clear disk, you can seek forever.
mervTormel is offline   Reply With Quote
Old 11-11-2002, 02:07 PM   #9
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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
baryonyx is offline   Reply With Quote
Old 11-11-2002, 02:20 PM   #10
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
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?
__________________
On a clear disk, you can seek forever.

Last edited by mervTormel; 11-11-2002 at 02:29 PM.
mervTormel is offline   Reply With Quote
Old 11-11-2002, 02:41 PM   #11
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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 is offline   Reply With Quote
Old 11-11-2002, 02:55 PM   #12
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
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
baryonyx is offline   Reply With Quote
Old 11-11-2002, 02:57 PM   #13
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
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
__________________
On a clear disk, you can seek forever.
mervTormel is offline   Reply With Quote
Old 11-11-2002, 03:03 PM   #14
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
merv, you are a bloody genius. Worked like a charm. Thank you.

Andy
baryonyx is offline   Reply With Quote
Old 11-13-2002, 09:26 AM   #15
occjph
Prospect
 
Join Date: Aug 2002
Location: orange county,ca
Posts: 18
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 {} \;
__________________
Per Ardua Ad Alta
occjph is offline   Reply With Quote
Old 11-13-2002, 09:38 AM   #16
baryonyx
Major Leaguer
 
Join Date: Jan 2002
Location: Bethesda, MD
Posts: 300
Have you submitted this as a tip to Rob's main page? I think you ought to--very tasty little tidbit.
baryonyx is offline   Reply With Quote
Old 04-07-2003, 03:19 PM   #17
Englabenny
Triple-A Player
 
Join Date: Feb 2003
Posts: 55
twin

similar thread:
http://forums.macosxhints.com/showth...3610#post53610
Englabenny is offline   Reply With Quote
Old 03-27-2007, 06:09 PM   #18
rmanke
Prospect
 
Join Date: Mar 2007
Posts: 12
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
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 is offline   Reply With Quote
Old 03-27-2007, 06:11 PM   #19
rmanke
Prospect
 
Join Date: Mar 2007
Posts: 12
Quote:
Originally Posted by rmanke
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.
rmanke is offline   Reply With Quote
Old 03-27-2007, 06:14 PM   #20
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by rmanke
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
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:06 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.