To delete files that were created 1 day ago in Linux, you can use the
find command in combination with the
rm command. Here's the step-by-step process:
- Open the terminal.
- Navigate to the directory where you want to delete the files. For example, if you want to delete files in the /path/to/directory directory, you can use the command cd /path/to/directory.
- Execute the following command to delete the files created 1 day ago:
find . -type f -mtime 0 -delete
Explanation of the command:
- find - The command used to search for files.
- . - Represents the current directory. You can replace it with the path to a specific directory if needed.
- -type f - Specifies that you are looking for files.
- -mtime 0 - Filters files with a modification time of 0 days (i.e., created today).
- -delete - Deletes the matching files.
After executing this command, all the files that were created 1 day ago in the specified directory will be deleted.