Write a script that finds the 10 largest files under / without crossing into other filesystems.
IntermediateHands-onBash scripting tasks
Answer
find / -xdev -type f -size +100M -printf '%s %p\n' 2>/dev/null | sort -rn | head -10 \
| awk '{printf "%.1f MB %s\n", $1/1048576, $2}'
Key trick → -xdev keeps find off /proc, NFS mounts and other volumes. -printf '%s' gives bytes for exact sorting.
More on Bash scripting tasks
Write the safe header you start every Bash script with, and explain each part.BeginnerWrite a script that alerts when any filesystem is above 80% usage.BeginnerParse an Nginx access log and print the top 10 client IPs by request count.BeginnerWrite a backup script that tars a directory with a timestamp and keeps only the last 7 backups.IntermediateWrite a health-check loop that polls a URL until it returns 200, with a timeout.IntermediateParse command-line flags `-e <env>`, `-v` (verbose) and `-h` in a Bash script.Intermediate