Linux / UNIX: Displaying Today’s Files Only

To display only today’s files in Linux or UNIX, you can use the “find” command with the “-daystart” and “-ctime” options. Here’s how to do it:

find /path/to/files -daystart -ctime 0

This command searches for files in the specified directory (/path/to/files in the example) that were created or modified within the last 24 hours. The “-daystart” option tells “find” to use the beginning of the current day as the reference time, rather than the current time. The “-ctime 0” option matches files that were changed within the last 24 hours.

You can also add other options to customize the search, such as “-type f” to only search for regular files, or “-name” to search for files with a specific name pattern.

find /path/to/files -daystart -ctime 0 -type f -name "*.txt"

This command searches for regular files in the specified directory (/path/to/files in the example) with a “.txt” extension that were created or modified within the last 24 hours.

By using the “find” command with the appropriate options, you can easily display only today’s files in Linux or UNIX.

Leave a Comment