View Full Version : Deleting a file called .
Bantik
04-10-2003, 03:18 PM
Really need help here... OS X 10.2 system. I copied a number of old OS 9 icons over to an OS X drive, then realized that I didn't want them after all. So I dragged the directory to the trash. Unfortunately, one of the files was named period (.), which has a special meaning in the UNIX world (current working directory). Now there is a file in my trash that cannot be deleted under any circumstance (or moved, renamed, etc.). I tried deleting it from under Classic, but Classic cannot see that particular volume.
Any ideas??
nkuvu
04-10-2003, 03:28 PM
Try rm \. in the Terminal...
(after getting to the Trash directory that has the file, that is)
Bantik
04-13-2003, 05:06 PM
Nope.
"rm: "." and ".." may not be removed"
grrl_geek
04-13-2003, 05:46 PM
I'm sorry if this is totally obvious, but when you say you tried to delete from Classic, does that mean from Classic within OS X, or booting into 9?
justinp
04-13-2003, 05:52 PM
Type "sudo rm " in the Terminal, then drag the file from the Trash into the Terminal window for the path. Hit enter and you'll be prompted for your Admin password. Put it in and the file should be deleted (you'll have to click in the trash window for it to refresh and show the change.
The code will look something like this sudo rm /Users/YourUserName/.Trash/.
EDIT: I'd test it, but I don't want a stubborn file either if it doesn't work. ;)
stetner
04-13-2003, 06:06 PM
'.' is the unix convention for the directory itself. Which in this case is .Trash
Try an 'ls -laqi' you should see something like:% ls -laqi
total 488
127808 drwxr-xr-x 92 stetner staff 3128 Apr 10 12:55 ./
8697 drwxr-xr-t 8 root wheel 272 Apr 8 11:01 ../
...
...
...
Are there one or two '.' files? There should always be one '.' file and one '..' file. '..' is the parent directory. Show us what you see.
fragerybou
04-13-2003, 07:53 PM
If the file itself is in the trash, and you have no need for aynthing else in the trash, why not rm -rf the trash folder, then make a new one with the same permissions as the old in its place? If it's in another folder, just try moving everything you need out from the folder, then deleting that folder. Not sure if it will work, but it might.
Another suggestion I read about earlier today would be to get the octal values of the file using a special ls flag, and rm -f <octalvalue filename>.
mervTormel
04-13-2003, 08:00 PM
Originally posted by fragerybou
... then make a new one with the same permissions as the old in its place...
you don't need to re-create the trash dir
Bantik
04-19-2003, 07:45 PM
None of the suggestions have worked so far. If I follow Stetner's advice, I get:
[/Volumes/Bit Foundry/.Trashes/501/DELETE ME]: ls -laqi
total 0
36026 drwxrwxrwx 3 bantik unknown 102 Apr 19 18:43 .
36026 drwxrwxrwx 3 bantik unknown 102 Apr 19 18:43 .
7302 drwx------ 3 bantik unknown 102 Apr 19 18:40 ..
rm -rf warns that the directory is not empty. All of this fails even when I've su'd.
stetner
04-20-2003, 01:00 AM
Originally posted by Bantik
[/Volumes/Bit Foundry/.Trashes/501/DELETE ME]: ls -laqi
total 0
36026 drwxrwxrwx 3 bantik unknown 102 Apr 19 18:43 .
36026 drwxrwxrwx 3 bantik unknown 102 Apr 19 18:43 .
7302 drwx------ 3 bantik unknown 102 Apr 19 18:40 .. Right, the first column in the output above is the inode number. Note that they are the same for both '.' files. This indicates corruption as there are two directory entries for '.'
The '3' in the third field indicates how many links there are to the directory, and since there are 3, any attempt to rmdir the directory will indicate it is not empty (an empty directory has two links, itself and its parent (..)).
I have had a similar problem in the past (should be listed in one of these forums somewhere) and I had to go into OS 9 and remove '.Trash' directory which worked.
Bantik
04-21-2003, 12:41 AM
Not all of my HD partitions are visible when I boot into OS 9, and I had (wrongly) assumed that the volume that this pesky file was on was one of them.
Here's the fix: launched Terminal; dragged the directory containing the extra . file into the terminal, to find out exactly where it was (/Volumes/BitFoundry/.Trashes/501/); rebooted into OS 9; launched ResEdit; modified both .Trashes and 501 on BitFoundry to set their visibility; dragged the 501 folder to the trash; emptied it.
Finally! Thanks for all of the help and suggestions.
Originally posted by Bantik
Not all of my HD partitions are visible when I boot into OS 9, and I had (wrongly) assumed that the volume that this pesky file was on was one of them.
Here's the fix: launched Terminal; dragged the directory containing the extra . file into the terminal, to find out exactly where it was (/Volumes/BitFoundry/.Trashes/501/); rebooted into OS 9; launched ResEdit; modified both .Trashes and 501 on BitFoundry to set their visibility; dragged the 501 folder to the trash; emptied it.
Finally! Thanks for all of the help and suggestions.
Just to confirm another idea above. I had a pesky file that would delete, so I did an rm ~/.trash and it got rid of everything in the trash (the trash folder too). The next time I put something in the waste basket, a new .trash file was created. So that should be a viable alternative.
jamesweb
08-24-2003, 09:18 AM
Seems to be quiet the same case : i need to delete two files with name with "\" character
The name files :
[CABLE]Alex_Timing_\xed\x99\xb6\xed\xb3\xa3lst
[CABLE]Alex_Timing_\xed\x99\xb7\xed\xb4\xa3l
Help needed, thank's in advance
cstuder
08-24-2003, 10:29 AM
Did you try
rm "[CABLE]Alex_Timing_\xed\x99\xb6\xed\xb3\xa3lst"
or
rm [CABLE]Alex_Timing_\\xed\\x99\\xb6\\xed\\xb3\\xa3lst
or simply with tab-completion?
Gruss aus dem Bernbiet :-),
christian
jamesweb
08-24-2003, 11:53 AM
Yes, i've done it but no success.
I don't know what is tab-completion, please explain
thank's in advance
bis bald :-)
hayne
08-24-2003, 12:19 PM
"Tab completion" refers to the use of the 'Tab' key to get the shell to complete the name of a file. You type the first part of the name, then press 'Tab' and the shell completes as much as it can.
Another thing to try might be 'rm -i *'. The use of the "-i" option makes it prompt you for confirmation before deleting a file. The "*" matches everything (all files) in the current folder. So, without the "-i", that command would delete everything in the folder. But if you use the "-i" it will ask you (yes or no) for each file - so you just reply "no" for each file except the ones you want to delete. Use Control-C to stop it once you have got to the files you want.
Ich hoffe, daß Sie erfolgreich alle Dateien löschen, die
Schrägstriche in ihren Namen haben.
;)
yellow
08-24-2003, 12:20 PM
Can you boot into 9 on your machine? If you can, then do that and delete the file.
jamesweb
08-24-2003, 05:39 PM
thank for your help but i have no mac classic installed on this machine
I know this tip but for my case, i need solution under macosx
jamesweb
08-24-2003, 05:49 PM
No success with the rm -i, sorry same problem with or without rm -i it's allways a name file problem
Error :
No such file or directory
Danke vielmal
stetner
08-24-2003, 05:59 PM
Originally posted by jamesweb
[CABLE]Alex_Timing_\xed\x99\xb6\xed\xb3\xa3lst
[CABLE]Alex_Timing_\xed\x99\xb7\xed\xb4\xa3l
If those are the only files with names like that you should be able to do:rm \[CABLE\]Alex_Timing_*Or, move all other files out of that directory and then do a 'rm -r' of the directory itself. BE CAREFUL with the 'rm -r' though, it is unforgiving.
yellow
08-24-2003, 09:04 PM
Err.. what about using Cocktail to turn on inivisible files in the Finder, then doing a Get Info on the bad file, and then renaming it in Get Info?
jamesweb
08-25-2003, 05:55 AM
even if the file if invisble or not, because the name contains strange characters "\" no renaming at all
hayne
08-25-2003, 06:15 AM
You didn't say whether you have tried stetner's suggestion of moving all the other files out of the folder and then removing the folder.
jamesweb
08-25-2003, 06:59 AM
Placing files into a junk folder to delete it after that = no success too
Same case if i try to stuff (and delete original) or tar or whatever stuff program
stetner
08-25-2003, 07:36 AM
Ok, let us see what we are dealing with. Can you issue these terminal commands in the directory where the files are and paste the output into a followup?
/bin/ls -alo
/bin/ls -lov | od -c
This will let us see if the 'immutable' flag has been set on anything and should show us if there are control characters in the file name. As well, what created these files, it may help to know that.
As well, it usually helps to see the exact output of the commands you try. Sometimes there is a bit of information there that makes one of us go 'oooohhh, now I see whats going on' :) So what happens exactly when you do the 'rm -r' on the junk directory?
PS. I have been giving the German->English translator at Babel Fish a good working out :)
Isn't there a way to delete files via the inode number? I could've sworn I saw some solution to problems like these on MacFixIt, but the "rm" man page doesn't seem to say anything about it.
stetner
08-25-2003, 08:11 PM
On a UFS file system you can use 'clri' but not on HFS+ unfortunately.
Klink
08-25-2003, 11:38 PM
OS X's virtual filesystem is kind of neato. ;)
For those special characters in your life...
cd into the directory which contains the file(s) with special characters.
cd /Users/Shared
Run an ls -i to list the inode number of the file in question.
ls -i
1203929 SC Info 2015029 ???AAAAA
Insert the inode number of the file one wishes to remove in the following command substitution. sudo when necessary.
find . -inum 2015029 -exec /bin/rm {} \;
jamesweb
08-26-2003, 03:16 AM
i know this way of solution but those files have no node number, that's why i'm trying to find a solution to list and erase files
I have no classic os installed on this machine to do this with a "normal" solution.
Files appear only by a ls -a and correct name only with a ls -a > test
and vi test let me see the entire names (see previous post for the diffenrence in names files)
stetner
08-26-2003, 04:13 AM
Could you humor us and post the output from these commands in the terminal?
/bin/ls -alo
/bin/ls -lov | od -c
ls -il
jamesweb
08-27-2003, 09:59 AM
and last one, result with ls- a
[james:~/desktop/aeffacer] thierryweber% ls -alo
ls:
ls:
total 0
drwxrwxr-x 4 thierryw staff - 136 Aug 25 12:00 .
drwxr-xr-x 16 thierryw staff - 544 Aug 26 01:37 ..
[james:~/desktop/aeffacer] thierryweber% ls -lov
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -lov | od -c
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -il
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -a
. .. [CABLE]Alex_Timing_??????lst [CABLE]Alex_Timing_??????l
[james:~/desktop/aeffacer] thierryweber%
hayne
08-27-2003, 11:12 AM
Okay, so it seems that these 2 files are the only things in that folder. So please show us what happens when you try to remove the whole folder with the following command?
rm -rf ~/desktop/aeffacer
stetner
08-27-2003, 07:44 PM
Originally posted by jamesweb
and last one, result with ls- a
[james:~/desktop/aeffacer] thierryweber% ls -alo
ls:
ls:
total 0
drwxrwxr-x 4 thierryw staff - 136 Aug 25 12:00 .
drwxr-xr-x 16 thierryw staff - 544 Aug 26 01:37 ..
[james:~/desktop/aeffacer] thierryweber% ls -lov
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -lov | od -c
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -il
ls:
ls:
[james:~/desktop/aeffacer] thierryweber% ls -a
. .. [CABLE]Alex_Timing_??????lst [CABLE]Alex_Timing_??????l
[james:~/desktop/aeffacer] thierryweber% So, it looks like there must be newlines or carriage returns in the names given those 'ls:' bits. Just to be sure, can you do a% which lsand/or use the full path /bin/ls. As well, try % /bin/ls -a | od -cIt looks looks like there are definitely 2 other files in the directory as the link count for '.' is 4 (1 for '.' one for '..' and 2 others).
trianglejuice
08-28-2003, 05:07 AM
According to my own experiences, there's a non-Unix solution on this problem:
When the file's not in the Trash, give it an extension (eg: .pdf)
Drag the file into your Trash
Restart your computer
When logged in, empty your trash
Normally the file is gone forever!
TriangleJuice.
yellow
08-28-2003, 08:25 AM
Originally posted by trianglejuice
According to my own experiences, there's a non-Unix solution on this problem:
When the file's not in the Trash, give it an extension (eg: .pdf)
Drag the file into your Trash
Restart your computer
When logged in, empty your trash
Normally the file is gone forever!
TriangleJuice.
This isn't possible since the file cannot be name-edited, cannot be seen in the Finder.
trianglejuice
08-28-2003, 08:52 AM
Originally posted by yellow
This isn't possible since the file cannot be name-edited, cannot be seen in the Finder.
And if you're logged in as root?
jamesweb
08-28-2003, 12:34 PM
two answers in one post :
-same result with ls or fullpath /bin/ls
-same result and reaction as root or "standard user"
one more time, please find hereby the name result of those two files (edited with vi after a ls -a > test)
.
..
[CABLE]Alex_Timing_\xed\x99\xb6\xed\xb3\xa3lst
[CABLE]Alex_Timing_\xed\x99\xb7\xed\xb4\xa3l
test
files have no node...
hayne
08-28-2003, 01:00 PM
I ask again:
Please show us what happens when you try to remove the whole folder with the following command:
rm -rf ~/desktop/aeffacer
stetner
08-28-2003, 06:04 PM
[james:~/desktop/aeffacer] thierryweber% ls -a
. .. [CABLE]Alex_Timing_??????lst [CABLE]Alex_Timing_??????l
[james:~/desktop/aeffacer] thierryweber% This output looks bizarre, hence the request for:
% /bin/ls -a | od -c
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.