Table of Contents
- Disk Usage / File Analysis
- AWS S3 commands
Disk Usage / File Analysis
Find out space taken by files older than 5 days
BASH
find . -type f -mtime +5 -print0 | du --files0-from=- -ch | grep totalKeep last 100d fies
BASH
ls -t | sed -e '1,100d' | xargs -d '\n' rm -f --BASH
truncate -s 50M catalina.outBASH
ls -d */Find out Year month of files
BASH
stat -c '%y' * | awk '{print $1}' | xargs -I{} date -d {} "+%b %Y" | sort -uList all files other than .gz
If you want this to do recursively:
BASH
find . -type f ! -name "*.gz"! -name "*.gz" → excludes .gz files
If you want only in current directory (no recursion):
BASH
find . -maxdepth 1 -type f ! -name "*.gz"AWS S3 commands
Download files of a particulat date (files having date format in name):
Here’s the AWS CLI command to download only the March 23 files:
BASH
aws s3 cp s3://<your-bucket-name>/ . --recursive --exclude "*" --include "*.2026-03-23.*"This uses --exclude “” to block everything, then --include “.2026-03-23.*” to selectively grab the three 2026-03-23 files.
s3 remove all files from a dir (prefix)
To remove all files from a directory (prefix) in S3:
BASH
aws s3 rm s3://your-bucket-name/your-prefix/ --recursiveThe --recursive flag deletes everything under that prefix.
Dry run – see what would be deleted without actually deleting:
BASH
aws s3 rm s3://your-bucket-name/your-prefix/ --recursive --dryrun