du -ks on certain directories only

Greetings,

I'd like to issue a command that would give me the disk usage total for certain directories. I used ls -lt|egrep 'Aug|Sep' to get a list of the directories I want, but I can't figure out how to feed that information to du. I'd like to do this as a command and not a script.

Many thanks,
Shambo

just like any other command that takes an argument you can use the forward ticks to execcute other commands which the output will be used for the arguments of the orignal command.

IE: rm `ls|grep old.files`
(this will remove all files that have old.files in the filename)

so if you go: du -options here `commands to find what you want to use du on`

take a look at my script and tear it apart and you can just use the commands you want.

#! /bin/ksh
#
# This will take a look at all Filesystems NOT left out in the variable FILESYSTEM and
# then find all directoy sizes listed in that filesystem and print them to standard output
# in a formated output. All sizes are in kb.
#
# by: Optimus_P aka me not you
#
FILESYSTEM=`df|awk '{ print $7 }'|grep -v Mounted`
#FILESYSTEM="/ /export/home /var /tmp"
for FS in ${FILESYSTEM};do
        USED=`df -k |grep $FS|awk '{ print ($2-$3) }'`
        FREE=`df -k|grep $FS|awk '{ print $3 }'`
        cd $FS
        echo "-=Disk Spaceing Script (all sizes are in kb)=-"
        echo '\t' by: me not you
        echo DISK $FS
        echo
        echo TOTAL AVAILABLE $FREE
        echo
        echo USED:
        echo '\t' $FS
        for DIRECTORY in `ls ${FS}`; do
                if [[ -d $DIRECTORY ]]; then
                        du -s $DIRECTORY|awk '{ printf ("%25s\t%-10d\n", $2,$1) }'
                fi
        done
        echo TOTAL USED ${FS}"\t"$USED
        echo
done