Here’s a step-by-step guide on how to get the list of all files with their size and creation date, filtering for files larger than 5MB, from an EC2 instance on a specific path:
- Connect to your EC2 instance: Use SSH or any other remote access method to connect to your EC2 instance.
- Navigate to the specific path: Use the
cd
command to navigate to the desired folder or directory where you want to retrieve the file information. - Run the command: Execute the following command to get the list of files with their size and creation date, filtering for files larger than 5MB:
find . -type f -size +5M -exec ls -lh {} \; | awk '{print $5, $6, $7, $8, $9}'
- Let’s break down the command:
find .
searches for files in the current directory and its subdirectories.-type f
specifies that only regular files should be considered (excluding directories and special files).-size +5M
filters files larger than 5MB.-exec ls -lh {} \;
executes thels -lh
command on each file found and prints the file size and other details.awk '{print $5, $6, $7, $8}'
extracts and prints the file size, creation month, day, and time.
- View the results: After running the command, you should see a list of files with their respective sizes and creation dates, filtered for files larger than 5MB.
{print $9}
part, which prints the file name and full path. When executed, it will display the file size, creation date, file name, and full path for each file larger than 5MB.