#!/bin/sh
#] 
#] *********************
#] $ bash  "$d_bin""du_sort.sh"  - sort sub-directory sizes for a single parent directory
# www.BillHowell.ca  21Jun2020 initial based on du_diff.sh


# 21Jun2020 - not useful yet, needs much more work!

dater=$(date +"%y%m%d %kh%Mm")

# d_temp defined at bash terminal startup

# arguments
#	-ch  		total of subdirs in human readable format
#	-t 1M  	-t, --threshold=SIZE
#           exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative
#	--max-depth=$1		-d, --max-depth=$1
#	$2, $3	filepath of [1st, 2nd] directories
#              

# 21Jun2020  checks 
# du  -ch  -t 1M  -d  1  "/home/bill/PROJECTS/"  |  sort    >"$d_temp""du1.txt"
# >> OK

# 21Jun2021 to double check backup.sh  as an example
# bash "$d_bin""du_diff.sh"   1    

#	dir="/home/bill/"
#	dir="$d_PROJECTS"
	dir="$d_webRawe"


#	dir="$d_HOWELL_BASE"
#	dir="$d_SWAPPER"
#	dir='/media/bill/Midas/'
#	dir='/media/bill/Seagate4Tb180804/'
#	dir="$d_base$d_sub"

#	dir='/media/bill/SWAPPER/Website - raw/Projects - mini/'


du -ch    --max-depth=1  "$dir"  |  sed "s#\(.*\)\t\($dir\)\(.*\)#\3\t\1#"   |  sort  |  sed "s#\(.*\)\t\(.*\)#\2\t\1#"     #>"$d_temp""du_sort.txt"


# old code


# -t 1M -  several important directories are very small for backups (eg secure ones)
# sort  "/media/bill/ramdisk/du temp.txt"  >"/media/bill/ramdisk/du temp2.txt"


# enddoc
