There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

some_guy ,

Off topic, but maybe someone will appreciate this. I wrote a function to get the size of contents of a dir a while back. It has a couple of dependencies (gc, gwc at a glance), but should be fairly portable. The results are sorted from greatest to least as shown in the screenshot.


<span style="color:#323232;">
</span><span style="color:#323232;">function szup() {
</span><span style="color:#323232;">
</span><span style="color:#323232;">description='
</span><span style="color:#323232;">#:    Title: szup
</span><span style="color:#323232;">#: Synopsis: sort all items within a directory according to size
</span><span style="color:#323232;">#:     Date: 2016-05-30
</span><span style="color:#323232;">#:  Version: 0.0.5
</span><span style="color:#323232;">#:  Options: -h | --help: print short usage info
</span><span style="color:#323232;">#:         : -v | --version: print version number
</span><span style="color:#323232;">'
</span><span style="color:#323232;">
</span><span style="color:#323232;">funcname=$(echo "$description" | grep '^#:    Title: ' | sed 's/#:    Title: //g')
</span><span style="color:#323232;">version=$(echo "$description" | grep '^#:  Version: ' | sed 's/#:  Version: //g')
</span><span style="color:#323232;">updated="$(echo "$description" | grep '^#:     Date: ' | sed 's/#:     Date: //g')"
</span><span style="color:#323232;">
</span><span style="color:#323232;">	function usage() {
</span><span style="color:#323232;">		printf "n%sn" "$funcname : $version : $updated"
</span><span style="color:#323232;">		printf "%sn" ""
</span><span style="color:#323232;">	}
</span><span style="color:#323232;">
</span><span style="color:#323232;">	function sortdir() {
</span><span style="color:#323232;">		Chars="$(printf "    %s" "inspecting " "$(pwd)" | wc -c)"
</span><span style="color:#323232;">		divider=====================
</span><span style="color:#323232;">		divider=$divider$divider$divider$divider
</span><span style="color:#323232;">		format="    %-${Chars}.${Chars}s %35sn"
</span><span style="color:#323232;">		totalwidth="$(ls -1 | /usr/local/bin/gwc -L)"
</span><span style="color:#323232;">		totalwidth=$(echo $totalwidth | grep -o [0-9]\+)
</span><span style="color:#323232;">		Chars=$(echo $Chars | grep -o [0-9]\+)
</span><span style="color:#323232;">		if [ "$totalwidth" -lt "$Chars" ]; then
</span><span style="color:#323232;">			longestvar="$Chars"
</span><span style="color:#323232;">		else
</span><span style="color:#323232;">			longestvar="$totalwidth"
</span><span style="color:#323232;">		fi
</span><span style="color:#323232;">		shortervar=$(/Users/danyoung/bin/qc "$longestvar"*.8)
</span><span style="color:#323232;">		shortervar=$(printf "%1.0fn" "$shortervar")
</span><span style="color:#323232;">		echo "$shortervar"
</span><span style="color:#323232;">		printf "n    %sn" "inspecting $(pwd)"
</span><span style="color:#323232;">		printf "    %$shortervar.${longestvar}sn" "$divider"
</span><span style="color:#323232;">		theOutput="$(du -hs "${theDir}"/* | gsort -hr)"
</span><span style="color:#323232;">		Condensed="$(echo -n "$theOutput" | awk '{ print $1","$2 }')"
</span><span style="color:#323232;">		unset arr
</span><span style="color:#323232;">		declare -a arr
</span><span style="color:#323232;">		arr=($(echo "$Condensed"))
</span><span style="color:#323232;">		Count="$(echo "$(printf "%sn" "${arr[@]}")" | wc -l)"
</span><span style="color:#323232;">		Count=$((Count-1))
</span><span style="color:#323232;">		for i in $(seq 1 $Count); do
</span><span style="color:#323232;">		read var1 var2 <<< "$(printf "%sn" "${arr[$i]}" | sed 's/,/ /g')"
</span><span style="color:#323232;">		printf "   %5s    %-16sn" "$var1" "${var2///*//./}"
</span><span style="color:#323232;">		done
</span><span style="color:#323232;">		echo
</span><span style="color:#323232;">	}
</span><span style="color:#323232;">
</span><span style="color:#323232;">	case "$1" in
</span><span style="color:#323232;">		-h|--help)
</span><span style="color:#323232;">			usage
</span><span style="color:#323232;">			return 0
</span><span style="color:#323232;">			;;
</span><span style="color:#323232;">		*)
</span><span style="color:#323232;">			:
</span><span style="color:#323232;">			;;
</span><span style="color:#323232;">	esac
</span><span style="color:#323232;">
</span><span style="color:#323232;">     if [ -z "$1" ]; then
</span><span style="color:#323232;">             oldDir="$(pwd)"
</span><span style="color:#323232;">             cd "${1}"
</span><span style="color:#323232;">             local theDir="$(pwd)"
</span><span style="color:#323232;">             sortdir
</span><span style="color:#323232;">             cd "$oldDir"
</span><span style="color:#323232;">             return 0
</span><span style="color:#323232;">     else
</span><span style="color:#323232;">     		:
</span><span style="color:#323232;">             oldDir="$(pwd)"
</span><span style="color:#323232;">             cd "${1}"
</span><span style="color:#323232;">             local theDir="$(pwd)"
</span><span style="color:#323232;">             sortdir
</span><span style="color:#323232;">             cd "$oldDir"
</span><span style="color:#323232;">             return 0
</span><span style="color:#323232;">     fi
</span><span style="color:#323232;">}```
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="color:#323232;">Screenshot isn't working. I'll reply to this with it.
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines