The script should list the disk storage occupied by each immediate subdirectory of a given argument or the current directory with the subdirectory names sorted in ABC order.
Also, list the name of the subdirectory with the highest disk usage along with its storage size.
If more than one subdirectory has the same highest disk usage, list any one of those subdirectories. Include meaningful brief comments.
This is what i have so far. When i use the head for some reason it wont show the name of the largest directory but the tail shows the name of the smallest and size. Any Help PLS?
Code:
# Display the Directories #
function list {
echo Disk space use (in KB) for each subdirectory
du --max-depth=1
}
fuction first {
echo Largest File
list | sort -n -r | head -n 1
}
function last {
echo Smallest File
list | sort -n -r | tail -n 1
}