Welcome to my Blog!
Information should be free, accurate, and available. I will be updating this section most often, enjoy!
Various galleries of artwork and photography I have done over the last five years.
Mini scripts I have written and decided to share. Mostly oneliners for managing network and system load.
Software projects are in the works and will be here eventually!
You can contact me through various methods.
This script will grab your current directory and measure every directory inside it and write the Disk/Inode usage to a file named "usage". This version is useful for cronjobs or for when you don't need to see the output until the script is finished.
Counting Total Inodes
When all you need is a count and don't care about where the files are located at:
$ find ~webuser/ | wc -l 1231
Or if all you care about is the total disk space being used by a user and don't care where the usage is:
$ du -sh ~webuser/
Organizing Inodes and Disk Usage
This script will search through the current directory and build a file usage list for you. It is a little ugly and breaks down using KB but it gets the job done nicely. Script as follows:
IFS=$'\012';
for d in `find . -type d`;
do s=$(ls -AlF $d | grep -v / | awk '{ $5 = $5/1024; sum += $5; } END \
{ print sum}') c=$(ls -AF $d|wc -l) ;
printf "%-20s" ${c} ${s}KB ${d} >>usage; printf "\n">>usage; doneThe output looks like:
$ head usage 15 4.59473KB . 0 0KB ./bt 0 0KB ./test_html 11 115.152KB ./public_html 31 6184.81KB ./public_html/images/ 3 0.0458984KB ./public_html/images/icons 13 357.815KB ./public_html/images/logos ...
This variation does the same thing, only it outputs the data to the screen as it is going into the file using the tee command. This would be more ideal for when you want to watch the search results instead of waiting for the script to finish to see the results.
IFS=$'\012';
for d in `find . -type d`;
do s=$(ls -AlF $d | grep -v / | awk '{ $5 = $5/1024; sum += $5; } END \
{ print sum}') c=$(ls -AF $d|wc -l) ;
printf "%-20s" ${c} ${s}KB ${d}; printf "\n"| tee -a usage; doneScripts for finding disk usage can be written in numerous ways. This are quick scripts I have whiped out for purposes of demonstration.
|
|
In America, our origins matter less than our destination, and that is
what democracy is all about.
-- Ronald Reagan, August 17, 1992