Artificial intelligent assistant

How to format "du" output to display filesize only? This is how I get a file size in MacOS: $ du -h "Anthem - Rush (Cover by Jewel Box).webm" 69M Anthem - Rush (Cover by Jewel Box).webm I want only **69M** in the output. **Anthem - Rush (Cover by Jewel Box).webm** is omitted. How to do that?

`du` reports the `d`isk `u`sage of files, not their (apparent) size.

The size of a file can be reported with `ls` and its `-l`/`-o`/`-g`/`-n` options (among other informations) or by various implementations of a `stat` utility with different and incompatible syntax or with the GNU implementation of `find` with its `-printf '%s\
'`.

The GNU implementation of `du` also has a `--apparent-size` for it to return the size instead of disk usage, however that can't be used for directories as for those types of files, `du` always adds the disk usage / size of all files referenced within.

So here, to get the size of a file after symlink resolution and with KMGTPE suffixes, on a GNU system, I'd do:


stat -Lc%s -- "$file" | numfmt --to=iec

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy df79c80139a5bb6db41813c149dd24d5