Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do you delete files in Terminal?

I've searched the site looking for this because I've had a problem deleting files before and know there's a way to do it in Terminal, but can't seem to find the answer. I have an application and two txt files that won't delete, and won't allow me to drag them to the trash or change the file name.
"The item cannot be moved to trash because it cannot be deleted."
I'm on OS 10.2.8, I do have admin privileges and the files are not locked.

If you can post the code to delete files in Terminal or if there is another option please let me know.

Thanks

g4, Mac OS X (10.2.x)

Posted on Oct 19, 2006 2:41 PM

Reply
3 replies
Sort By: 

Oct 19, 2006 3:02 PM in response to mbungo

Hi bungoooo,

First of all, Welcome to the Apple Discussion Forums!

Have a read of Dr. Smoke's excellent FAQ "Solving Trash Problems".

Follow all suggestions carefully especially when using the Terminal!

That's pretty much all you will need to know about deleting stubborn files!

littleshoulders [:-)
Reply

Oct 19, 2006 9:36 PM in response to mbungo

Force-delete an item from desktop or Trash....this also will remove a locked
file/application .... or ... a “file that is in use”
1. Launch Terminal...type/copy/paste...
rm <space> This deletes a file only
sudo rm -rf <space> ..this deletes file or folder ,,,or ...
sudo rm -R <space> this deletes file or folder
2. Drag the offending item into the Terminal window. The path to it will appear.
•To force-delete more than one item from the trash....click a item and press Shift or Command as you click additional items .
3. Click on Terminal window, press .... Enter
4. type your administrator password. Press ....Enter
5. Click on the Desktop or the Trash window and the file will vanish.
• If this does not work, then visit The XLab FAQs ....
http://www.thexlab.com/faqs/faqs.html
and read the FAQ on Trash problems for additional solutions.

george
Reply

Oct 20, 2006 1:46 AM in response to mbungo

In Terminal:
move to your folder where your file are:
$ cd /Desktop/MyFolder
See what's inside your folder
$ ls
Erase the files one by one:
$ rm file1.txt
$ rm file2.txt
etc...
Erase all the files and folder in the folder where you are:
$ rm -Rf ./*

* Be careful with the last one if you are in your desktop folder you erase everything in it *

David
Reply

How do you delete files in Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.