Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > unlink/delete file

unlink/delete file
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Jun 28, 2003, 11:53 AM
 
I have a file/folder in my trash from a separate hard drive. I cannot empty it in the trash because it is "locked". I am logged in as root, but I cannot empty it because I don't have "permission". I have attempted ALL the "empty Trash" programs there are out there, but none will do the deal...

Finally, I started trying to empty it from the terminal (being assured by a versiontracker ref. that this would ABSOLUTELY do it), but was again told that I was either performing an "illegal operation", or didn't have "permission" (or both) and to "unlink" the file first. Well, I went to the man page to reference unlinking a file, but I'm not understanding how to use the commnd ().

Does any one have any suggestions, ideas, insights, or solutions???

I have had this thing in my trash for over a month now and still haven't figured out how to elininate it!

     
Senior User
Join Date: Jan 2001
Location: Mahwah, NJ USA
Status: Offline
Reply With Quote
Jun 28, 2003, 01:44 PM
 
Originally posted by nuventure:
I have a file/folder in my trash from a separate hard drive. I cannot empty it in the trash because it is "locked". I am logged in as root, but I cannot empty it because I don't have "permission". I have attempted ALL the "empty Trash" programs there are out there, but none will do the deal...

Finally, I started trying to empty it from the terminal (being assured by a versiontracker ref. that this would ABSOLUTELY do it), but was again told that I was either performing an "illegal operation", or didn't have "permission" (or both) and to "unlink" the file first. Well, I went to the man page to reference unlinking a file, but I'm not understanding how to use the commnd ().

Does any one have any suggestions, ideas, insights, or solutions???

I have had this thing in my trash for over a month now and still haven't figured out how to elininate it!

Try:

sudo rm -Rf /path/to/folder

Be VERY careful with that command! An inadvertent space such as:

sudo rm -Rf / path/to/folder

will wipe your entire system... and it won't ask you if you really want to do it or not. Somewhat safer way to use it is:

cd /path/to/
sudo rm -Rf folder/
-DU-...etc...
     
Zim
Senior User
Join Date: Apr 2001
Location: Cary, NC
Status: Offline
Reply With Quote
Jun 29, 2003, 10:51 AM
 
Uh, it would be safer to (in Terminal)

cd ~/.Trash (assuming in your home trash)

ls -al (confirm the offending file is there)

rm -f filename

if that fails

sudo rm -f filename

Mike
     
Fresh-Faced Recruit
Join Date: Sep 2002
Location: London
Status: Offline
Reply With Quote
Jun 29, 2003, 01:23 PM
 
Originally posted by nuventure:
I have a file/folder in my trash from a separate hard drive.
If the file/folder is from a separate hard drive, it is probably not in your ~/.Trash folder, but in /Volumes/someVolume/.Trashes/501 (or whatever your UID is).

If you can't get rid of it, it may be locked. To find out what is going on, type these commands (cut and paste one line at a time) and post your results:
Code:
ls -aolR .Trash ls -aolR /Volumes/*/.Trashes/`id -u`
This may help to identify the problem.
     
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Jun 29, 2003, 05:54 PM
 
Actually, it IS a locked file in the trash of another volume (PLUS its invisible, PLUS it has a "+" character in ithe file's name!

Double Help!!
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Jun 29, 2003, 10:13 PM
 
Originally posted by nuventure:
Actually, it IS a locked file in the trash of another volume (PLUS its invisible, PLUS it has a "+" character in ithe file's name!
   You can unlock a file from the command line with the following:

sudo chflags nouchg <filename>

Of course you don't need sudo if you own the file but in that case you could unlock it in the Finder. If you have Apple's Developer Tools, the SetFile command can also be used to unlock files. To do any of this from the command line, you must know exactly where the file is and given that the Trash is actually a collection of directories, this can be problematic. The easiest way to get the exact path is simply drag the file to the Terminal. However, there are also AppleScript commands that will return the POSIX path to the file.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Mac Enthusiast
Join Date: Jul 2002
Location: Leiden, Netherlands
Status: Offline
Reply With Quote
Jun 30, 2003, 02:58 AM
 
Originally posted by nuventure:
Actually, it IS a locked file in the trash of another volume (PLUS its invisible, PLUS it has a "+" character in ithe file's name!

Double Help!!
Use the rm method given above. You need to protect the filename with ' ' in order to get rid of the "+" annoyance.
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Jun 30, 2003, 06:30 AM
 
Originally posted by Ludovic Hirlimann:
Use the rm method given above. You need to protect the filename with ' ' in order to get rid of the "+" annoyance.
Why? What shell considers a "+" to be a special character in a filename?
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:09 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2