How to Delete Files on a Particular Date with Unix

Can anybody please tell me how to delete all the files on a particular date in Unix? for example, I have a list of files: Nov 9 12:30 test, Nov 9 14:45 test 2, Nov 9 18:15 quick, Nov 10 07:20 quick 2...Now I would like to delete the file quick 2 created on Nov 10..... What would be the command?

Best Answered by

Dany· Answered on Jan 20, 2023

You can use two command lines to precisely find and delete files at a particular time. First, you can search for files whose last modification time is older than X minutes, days, months, or years using bash in Unix. Here is the Command Prompt for searching the specific file(s).

find / -name "your-directory" -mtime +XX -exec rm -f {}; Specify path, filename and time to delete the file.

The description of the Command line is as follows:

  • find - the command that finds the files.
  • ./your-directory - the absolute or relative path to the location of the search. I believe that using absolute routes will prevent future issues.
  • -mtime +XX - replace XX with the days you want to return. 
  • -exec rm -f {}; - this deletes files that match the particular settings.

It is safe to execute the preceding command since it will only produce a list of files that fit the search criteria; they will not be destroyed or modified; for example, a possible output might be: ./your-directory/file1.xd

As previously stated, my script's final phase was removing the files that matched the search more simpler. Fortunately, the most challenging step was completed. To erase the result of your search, add the -delete parameter to the search command:

find ./your-directory -daystart -maxdepth 1 -mmin +10 -type f -delete

When you delete a file or directory in Linux or Unix, it does not disappear forever. There are a few tiers of folders where deleted files can go before being completely removed from your system. So you can recover deleted files in Linux or Unix effortlessly. 

EaseUS Data Recovery Wizard can recover deleted files or folders on Linux. By downloading, you can access free recovery from various data loss situations and preview before recovery. Simply put, you can connect the Unix disk to a Windows PC and retrieve files. Download EaseUS to use its capabilities and recover your lost files for free.

Use EaseUS Data Recovery Wizard to recover deleted or lost files easily and quickly.

Tutorials on how to recover lost, deleted, or formatted data from HDD, SSD, USB, SD card, or other storage media on Windows and Mac.

People Also Ask

How to Fix Files with Long Filenames Will Not Delete

When users change a short filename to a name that is too long, the file may not be deleted normally. The system will warn you that your filename is too long or your file cannot be found. We will help you out of this trouble in this passage.


Jan 18, 2023

Is There Linux Software to Recover Deleted Videos and Images

In Linux, how can I retrieve data that have been permanently erased in Linux? This tutorial will walk you through restoring deleted data in Linux Redhat, Ubuntu, Manjaro, Mint, and Debian. To always convert deleted files in Linux, use EaseUS Linux data recovery software.


Jan 16, 2023

How to Delete Files Across a Domain Remotely

You can configure a shortcut item to solve this problem. Using the Shortcut preference settings, you can configure a shortcut to a file system object. Before you build a Shortcut preference item, you should examine the behavior of each sort of action that this extension supports.


Jan 05, 2023

How to Delete Hacker Files to Free Up Space on Windows

Virus attacks and malware may cause chaos on your computer, and you may not be able to delete some files. We will help you remove the files with CMD and show you how to format the hard drive.


Jan 18, 2023

How to Delete Files from Archive by Text File

Renaming a file within a zip bundle is similar. Even in these circumstances, you can extract everything before zipping it back into a new file or overwriting the old one. So, keep reading this post to acquire the 2023 guide.


Jan 05, 2023

How to Do File Recovery from an SD Card Without Backup

SD cards are widely utilized due to their fast data transmission speed and hot-swappable features, yet several data loss issues plague them. If you mistakenly remove files from your SD card, don't panic; there are various recovery methods and SD recovery software that can assist you in recovering deleted items from your SD card.


Dec 21, 2022