Simplify Disk Space Analysis with TopNDiskAnalyzer
....................................................................................................................
Introduction
Managing and understanding file sizes within a directory is a common task for developers, sysadmins, sre, and users. To simplify this process, I've created a tool called TopNDiskAnalyzer. This tool allows users to analyze and retrieve the top N files and folders based on their sizes within a specified directory.
Features
- Concurrent Processing
TopNDiskAnalyzer leverages concurrent processing to efficiently analyze files and folders concurrently. This is achieved by utilizing goroutines in Go, ensuring optimal performance, especially when dealing with large directory structures.
- Dynamic Top N
One notable feature of TopNDiskAnalyzer is its ability to dynamically set the 'N' value for the top files and folders. Users can provide the desired count using the --top
command-line argument. If not specified, the default value is 10.
- Informative Output
The tool produces insightful output, displaying the top files and folders along with their sizes in a human-readable format. The sizes are presented in KB, MB, GB, etc., making it easy for users to comprehend.
Getting Started
Installation
Download Binary
You can download the precompiled binary for your operating system from the releases page.
Linux:
# 64-bit
wget https://github.com/GirishCodeAlchemy/TopNDiskAnalyzer/releases/download/v1.0.0/tdf-linux-amd64 -O tdf
chmod +x tdf
sudo mv tdf /usr/local/bin/
# 32-bit
wget https://github.com/GirishCodeAlchemy/TopNDiskAnalyzer/releases/download/v1.0.0/tdf-linux-386 -O tdf
chmod +x tdf
sudo mv tdf /usr/local/bin/
macOS:
# 64-bit
wget https://github.com/GirishCodeAlchemy/TopNDiskAnalyzer/releases/download/v1.0.0/tdf-darwin-amd64 -O tdf
chmod +x tdf
sudo mv tdf /usr/local/bin/
Windows:
Download the tdf.exe from the releases page.
Build from Source
If you prefer to build from a source, make sure you have Go installed. Clone the repository and run the following commands:
git clone https://github.com/GirishCodeAlchemy/TopNDiskAnalyzer.git
cd TopNDiskAnalyzer
go build -o tdf main.go
sudo mv tdf /usr/local/bin/
This will provide users with clear instructions on how to download and install your TopNDiskAnalyzer tool on various operating systems.
Usage
Once installed, you can use the tool by running the following command:
tdf [options] [directory_path]
Options
--dir
: Specifies the directory path. Defaults to the current directory.--top
: Specifies the number of top items to display. Defaults to 10.--help
: Displays helpful information about the program and its options.
The command recursively analyzes the specified directory, calculating the sizes of files and folders, and then displays the top items based on their sizes in descending order.
Examples
# Analyze the current directory, display top 10 items
tdf
# Analyze a specific directory, display top 15 items
tdf --top 15 /path/to/directory
# Analyze a specific directory (using positional argument), display top 10 items
tdf /path/to/directory
# Help
tdf --help
Screenshots
Here are some screenshots illustrating the usage of TopNDiskAnalyzer:
Help Command
Relative Path
Absolute Path
Top Option
Conclusion
TopNDiskAnalyzer provides a straightforward solution for users who need quick insights into the largest files and folders within a directory. Its concurrent processing, dynamic top N feature, and informative output make it a valuable tool for various use cases.
To get started, check out the GitHub repository and feel free to contribute or provide feedback.
🙏Thank you for reading...
✈️ Linkedin: https://www.linkedin.com/in/vgirish10/