Delete files and folders via SSH

To delete a file using SSH, you’ll need to execute the appropriate command – rm.

The command looks like this:

rm myFile.txt myFile1.txt myFile2.txt …etc…

However, listing all files/folders that need to be deleted can be quite time consuming. Fortunately rm accepts several arguments which can make your job easier. In the above example you could type:

rm myFile*.txt

This will match all files starting with ‘myFile’ and ending in ‘.txt’

To delete a whole folder and its content recursively, you can use:

rm -rf foldername/

To delete all files/folders in the current directory without deleting the directory itself, you would need to use:

rm -rf *

Michael Savin

My name is Michael Savin. I've been contributing to the Internet for over ten years and have been a London based Magento freelancer for the last six.

I build eCommerce websites for varied companies worldwide and enjoy a close relationship with many brands, freelancers and studios. Work aside I enjoy cycling, reading and long walks in sunny days.

2 Comments

  1. Hello, I need some help with it. When I try to go to magento front page it pops up this: Warning: smpmlexil_load_string(): Entity: line 2: parser error : Comment not terminated. Nothing is shown in system.log about this as well. I don’t know where to put Mage::log(print_r($filename, true)); to help me find this error.Help please.

    1. Apologies, just saw this now. Do you still need help with this?

Leave a Reply

Your email address will not be published. Required fields are marked *