Only get the size from "du" command, not the folder names
Specifying both -k
and -m
does not make sense: either you want 1-Mbyte or 1-Kbyte blocks. Also -h
does not make sense in combination with -k
and -m
. Only the last one -m
will be considered
You can use cut
to remove anything after the space:
du -sm /Users/JS_Admin/Desktop | cut -f1
With -f
you specify which field you need (in this case the first one).
An approach using awk
.
du -s /path/to/folder | awk '{ print $1 }'
$1
refers to the first column. And regarding du -s
:
-s, --summarize
display only a total for each argument