#! /bin/bash declare -a line declare tot_bytes=0 declare tot_files=0 declare nf=0 declare temp=$(mktemp) ls -l $* | while read -a line; do nf=${#line[*]} if (( nf == 8 )); then if [[ "${line[0]:0:1}" == "-" ]]; then (( tot_bytes += ${line[4]} )) (( tot_files++ )) echo -e ${line[4]} "\t" ${line[7]} elif [[ "${line[0]:0:1}" == 'd' ]]; then echo -e '