The lines of code work fine run individually in Xterm.
But in the script it only gets the first file, not the whole wildcard list.
Code: Select all
#!/bin/sh
##### Get total size of files by wildcard argument.
if [ -z "$1" ];then exit ;fi
FILES=`du $1`
#FILES=`ls -1l $1 | awk '{print $5, $8}'`
echo '### FILES'
echo "$FILES"
SIZES=`echo "$FILES" | awk '{print $1}'`
echo '### SIZES'
echo "$SIZES"
ADD=`echo $SIZES | sed 's/ / + /g'`
echo '### $ADD'
echo "$ADD"
echo '============================================='
echo "$FILES"
echo '================================'
echo `expr $ADD`' Total of File Sizes.'
If you run either line in Xterm it gives all the matching files and sizes.