Disk Usage Analyzer Bash Script

marius

Administrator
Staff member
Introduction:
This bash script quickly summarizes the disk usage of directories, helping you monitor storage on your system.

Code Snippet:
Bash:
#!/bin/bash
# Disk Usage Analyzer
if [ -z "$1" ]; then
  echo "Usage: $0 <directory>"
  exit 1
fi

du -sh "$1"/*

Instructions:
To use the script, first make it executable and then run it with the target directory:
Code:
chmod +x disk_usage_analyzer.sh
./disk_usage_analyzer.sh /path/to/directory

Example Output:
Code:
4.0K   /path/to/directory/file1
16K    /path/to/directory/file2
 
Back
Top