At first you have to fix the ls issue that it doesn't include the total with the following function:
myls() {
if [ $# -gt 1 ] ; then
ls -1sh "$@"
ls -1s "$@" | cut -d' ' -f1 | awk '{s+=$1} END {print s}' | numfmt --to=iec --suffix=' total'
else
ls -1sh "$1"
fi
}
You can put that in your .bashrc and load it.
After that you have to combine the outputs. There are multiple ways to do that. Here is one:
First you combine all the outputs with paste.
unfortunately paste only accepts files as arguments but you can use named pipes to take care of that:
combined() {
paste <(wc -l "$@") <(myls "$@") | awk '{print $1, $3, $4}' | sort
}
You can put this function in your .bashrc now. I sorted them because I think that is mode readable. You can remove | sort if you don't want to sort them.
If you don't want to use an extra function you can do:
myd() {
if [ $# -gt 1 ] ; then
tmp=`ls -1sh "$@";ls -1s "$@" | cut -d' ' -f1 | awk '{s+=$1} END {print s}' | numfmt --to=iec --suffix=' total'`
else
tmp=`ls -1sh "$1"`
fi
paste <(wc -l "$@") <(echo "$tmp") | awk '{print $1, $3, $4}' | sort
}
ls -1shmay also print directory itemsls -1shon the folder which contains subfolders, you'll see. In your case you can not getwc -lfrom subfolderwc -l(which counts lines in a text file) on a .png image file?