Documentation: add du command to NSH commands reference
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions

Add a reference section for the NSH `du` command, covering the -h,
-s, -a, and -d N options, default-to-current-directory behavior,
and an example showing recursive directory output.

Options are rendered as an RST simple table to match the style of
other NSH command sections (ls, umount, uptime). Sizes are noted as
apparent sizes (st_size) and -h as integer-arithmetic, one-decimal
output that needs no float printf support.

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
This commit is contained in:
Junbo Zheng 2026-07-23 23:20:43 +08:00 committed by simbit18
parent 990825110d
commit 609528dabb

View file

@ -431,6 +431,47 @@ that in-memory, circular buffer to the NSH console output.
``dmesg`` has the side effect of clearing the buffered data so
that entering ``dmesg`` again will show only newly buffered data.
.. _cmddu:
``du`` Estimate File Space Usage
================================
**Command Syntax**::
du [-h] [-s] [-a] [-d N] <path>...
**Synopsis**. Recursively summarize the apparent size of each
``<path>`` in 1K-blocks, or in human-readable form with ``-h``. If
no ``<path>`` is given, the current working directory is used. As
an example::
nsh> du
397449 /data/test/elf
71993 /data/test/coredump
5 /data/test/log2
3251 /data/test/log1
472700 /data/test
nsh> du -h
388.1M /data/test/elf
70.3M /data/test/coredump
4.1K /data/test/log2
3.1M /data/test/log1
461.6M /data/test
nsh>
**Options**
======== ===========================================================
``-s`` Summary only: print only the total for each ``<path>``.
``-a`` List all files, not only directories.
``-d N`` Print at most N directory depth levels.
``-h`` Human-readable sizes (K/M/G, one decimal; ``B`` below 1K).
======== ===========================================================
Sizes are apparent sizes (``st_size``), not block usage. ``-h``
prints one decimal using integer arithmetic and does not require
float printf support.
.. _cmdecho:
``echo`` Echo Strings and Variables