help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sorting directories by size


From: hancooper
Subject: Sorting directories by size
Date: Tue, 24 Aug 2021 02:21:28 +0000

I have a directory stored in `dir`. I want to store the names of directories at 
a particular level
and sort them by size.

I have started with listing the directory names in `dlc` and computing the 
total number of
directories present. But still have to sort `dlc` by size, the with the biggest 
first.

My initial plan is to use a command such as `du -h | sort -h`.

daggr=( -mindepth "$depth" -maxdepth "$depth" )
dlc=$( find "$dir" "${daggr[@]}" -type d | tr "\n" " " )
ndr=$( echo "$dlc;" | grep -o " " | wc -l )

reply via email to

[Prev in Thread] Current Thread [Next in Thread]