Removing Files via SSH Permalink: Removing Files via SSH Bookmark Icon

I needed to delete a lot of files from a web server and it was taking forever. To get this done faster, I looked into removing the files via SSH. The following handy lines of code let you find or delete all files and folders within a certain directory.

To find all files and folders at least one level deep in the specified directory, type:

find <name-of-directory or path> -mindepth 1

To delete all files and folders inside the specified directory, type this:

find <name-of-directory or path> -mindepth 1 -delete

As always, use this command with caution.


Leave a comment

Available formatting commands

Use Markdown commands or their HTML equivalents to add simple formatting to your comment:

Text markup
*italic*, **bold**, ~~strikethrough~~, `code` and <mark>marked text</mark>.
Lists
- Unordered item 1
- Unordered list item 2
1. Ordered list item 1
2. Ordered list item 2
Quotations
> Quoted text
Code blocks
```
// A simple code block
```
```php
// Some PHP code
phpinfo();
```
Links
[Link text](https://example.com)
Full URLs are automatically converted into links.

Replied on your own website? Send a Webmention!