Command
$ tree --version;
# tree v2.1.1 © 1996 - 2023 by Steve Baker, Thomas Moore, Francesc Rocher,
# Florian Sesser, Kyosuke Tokoro
# -x - Stay on the current file-system only...
# -a - All files are printed... (those beginning with a dot `.')...
# -p - Print the file type and permissions for each file...
# -u - Print the username, or UID...
# -g - Print the group name, or GID...
# -h - Print the size of each file but in a more human readable way...
# -F - Append a `/' for directories, a `=' for socket files...
# -D - Print the date of the last modification time...
# --du - For each directory report its size as the accumulation of sizes...
# --dirsfirst - List directories before files...
# --charset - Set the character set to use when outputting...
# --sort - Sort the output by type instead of name...
# --timefmt - Prints... and formats the date according to the format string...
#
tree -xapughFD \
--du --dirsfirst \
--charset='ascii' --sort='size' --timefmt='%Y-%m-%d_%H-%M-%S' -- \
. \
| grep -P '^(?:\|\s{3}|\s{4}){0,1}(?:`|\|)\-\-';
In the grep
regex, {0,1}
(frankly, is similar to ?
) may be used for the "depth". For example, {0,3}
would be for the current and maximum of 3 directories into deep.
Example
$ cd /usr/share/ffmpeg/; pwd -P;
/usr/share/ffmpeg
$ tree -xahpugFD --du --charset=ascii --dirsfirst --sort=size --timefmt='%Y-%m-%d_%H-%M-%S' -- . | grep -P '^(?:\|\s{3}|\s{4}){0,1}(?:`|\|)\-\-';
|-- [drwxr-xr-x root root 194K 2022-02-01_19-47-55] examples/
| |-- [-rw-r--r-- root root 28K 2019-04-04_10-39-16] transcode_aac.c
| |-- [-rw-r--r-- root root 21K 2019-04-04_10-39-16] muxing.c
| |-- [-rw-r--r-- root root 20K 2019-04-04_10-39-16] transcoding.c
| |-- [-rw-r--r-- root root 19K 2019-04-04_10-39-16] decoding_encoding.c
| |-- [-rw-r--r-- root root 15K 2019-04-04_10-39-16] demuxing_decoding.c
| |-- [-rw-r--r-- root root 14K 2019-04-04_10-39-16] qsvdec.c
| |-- [-rw-r--r-- root root 12K 2019-04-04_10-39-16] filter_audio.c
| |-- [-rw-r--r-- root root 9.9K 2019-04-04_10-39-16] filtering_audio.c
| |-- [-rw-r--r-- root root 9.0K 2019-04-04_10-39-16] filtering_video.c
| |-- [-rw-r--r-- root root 7.8K 2019-04-04_10-39-16] resampling_audio.c
| |-- [-rw-r--r-- root root 5.6K 2019-04-04_10-39-16] extract_mvs.c
| |-- [-rw-r--r-- root root 5.5K 2019-04-04_10-39-16] avio_dir_cmd.c
| |-- [-rw-r--r-- root root 5.5K 2019-04-04_10-39-16] remuxing.c
| |-- [-rw-r--r-- root root 5.1K 2019-04-04_10-39-16] http_multiclient.c
| |-- [-rw-r--r-- root root 4.9K 2019-04-04_10-39-16] scaling_video.c
| |-- [-rw-r--r-- root root 4.0K 2019-04-04_10-39-16] avio_reading.c
| |-- [-rw-r--r-- root root 1.9K 2019-04-04_10-39-16] metadata.c
| |-- [-rw-r--r-- root root 1.7K 2019-04-04_10-39-16] Makefile
| `-- [-rw-r--r-- root root 888 2019-04-04_10-39-16] README
|-- [-rw-r--r-- root root 19K 2019-04-04_10-39-16] ffprobe.xsd
|-- [-rw-r--r-- root root 227 2019-04-04_10-39-16] libvpx-1080p50_60.ffpreset
|-- [-rw-r--r-- root root 227 2019-04-04_10-39-16] libvpx-1080p.ffpreset
|-- [-rw-r--r-- root root 227 2019-04-04_10-39-16] libvpx-720p50_60.ffpreset
|-- [-rw-r--r-- root root 227 2019-04-04_10-39-16] libvpx-720p.ffpreset
`-- [-rw-r--r-- root root 219 2019-04-04_10-39-16] libvpx-360p.ffpreset
Source: https://unix.stackexchange.com/a/769124/133353