The following command is used to find all laravel.log
files within the /var/www
directory (or any specified directory) and display their last modification time along with the file name:
find /var/www -name "laravel.log" -exec stat --format="%y %n" {} +
Command Breakdown:
find /var/www -name "laravel.log"
- Searches for files named
laravel.log
within the /var/www
directory and its subdirectories. - You can replace
/var/www
with any directory path where you want to search.
-exec stat --format="%y %n" {} +
- For each file found:
stat
retrieves detailed information about the file.--format="%y %n"
formats the output to show:%y
: The last modification time of the file.%n
: The full file name.
Purpose of the Command:
This command is particularly useful for systems where the ls --time=modification
option is not supported. It provides an efficient way to:
- Locate specific log files (
laravel.log
) in a directory. - Display the last modification time and file name in a clean, formatted output.
Example Output:
Running the command may produce output like this:
2024-12-06 10:32:45.123456789 /var/www/project1/storage/logs/laravel.log
2024-12-05 18:25:10.987654321 /var/www/project2/storage/logs/laravel.log
This clearly shows the last modification time and the full path of each laravel.log
file.
Key Advantages:
- Comprehensive Search: Finds files recursively in the specified directory.
- Clear Output: Displays both modification time and file path in a readable format.
- Cross-Compatibility: Works on systems without
ls --time=modification
.
You can adapt the command for other file types or directories as needed.