AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[ncdu](unix)

Martin Hope
Franck Dernoncourt
Asked: 2025-02-10 07:44:50 +0800 CST

我如何配置 ncdu 以便它使用整个屏幕的高度?

  • 4

我在 Ubuntu 20.04.5 LTS (Focal Fossa) 上使用ncdu。我通过 JupyterLab 中的终端访问它。我该如何配置ncdu才能让它使用整个屏幕的高度?

下面的截图显示ncdu没有使用整个屏幕的高度:

在此处输入图片描述

$LINES和的值$COLUMNS:

user@server:~/tmp$ echo $LINES $COLUMNS
35 94

我希望有:

在此处输入图片描述

ncdu
  • 1 个回答
  • 28 Views
Martin Hope
Gabriel Staples
Asked: 2022-02-08 08:32:05 +0800 CST

bash:使`du`显示类似于`ncdu`的输出

  • 4

ncdu在 Linux 上,以下是NCurses 磁盘使用工具的一些示例输出:

命令:

ncdu /boot
ncdu 1.14.1 ~ Use the arrow keys to navigate, press ? for help 
--- /boot -----------------------------------------------------
  100.2 MiB [##########]  initrd.img-5.13.0-28-generic         
  100.2 MiB [######### ]  initrd.img-5.13.0-27-generic
   11.2 MiB [#         ]  vmlinuz-5.11.0-46-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-28-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-27-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-25-generic
    8.0 MiB [          ] /grub
    5.7 MiB [          ]  System.map-5.13.0-28-generic
    5.7 MiB [          ]  System.map-5.13.0-27-generic
    5.7 MiB [          ]  System.map-5.13.0-25-generic
    5.6 MiB [          ]  System.map-5.11.0-46-generic
  252.0 KiB [          ]  config-5.13.0-28-generic
  252.0 KiB [          ]  config-5.13.0-27-generic
  252.0 KiB [          ]  config-5.13.0-25-generic
  252.0 KiB [          ]  config-5.11.0-46-generic
  184.0 KiB [          ]  memtest86+_multiboot.bin
  184.0 KiB [          ]  memtest86+.elf
  180.0 KiB [          ]  memtest86+.bin
!  16.0 KiB [          ] /lost+found
!   4.0 KiB [          ] /efi
@   0.0   B [          ]  initrd.img.old
@   0.0   B [          ]  initrd.img
@   0.0   B [          ]  vmlinuz.old
@   0.0   B [          ]  vmlinuz

但是,它是一个人机交互程序,并且输出不可编写脚本。我想将它存储到一个变量中,那么,我怎样才能获得类似的输出du呢?

这是我的问题的后续问题:如何ncdu快速显示磁盘使用情况并退出?

最终用途将如下所示:

output_before="$(du /boot)"
# do a bunch of stuff here which reduces the size of /boot
output_after="$(du /boot)"
echo "Before:"
echo "$output_before"
echo ""
echo "After:"
echo "$output_after"

这是一个开始,但它没有以正确的从大到小的降序显示输出:

du --all --max-depth=1 -h /boot

我最想看到的:

--- /boot -----------------------------------------------------
  100.2 MiB [##########]  initrd.img-5.13.0-28-generic         
  100.2 MiB [######### ]  initrd.img-5.13.0-27-generic
   11.2 MiB [#         ]  vmlinuz-5.11.0-46-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-28-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-27-generic
    9.7 MiB [          ]  vmlinuz-5.13.0-25-generic
    8.0 MiB [          ] /grub
    5.7 MiB [          ]  System.map-5.13.0-28-generic
    5.7 MiB [          ]  System.map-5.13.0-27-generic
    5.7 MiB [          ]  System.map-5.13.0-25-generic
    5.6 MiB [          ]  System.map-5.11.0-46-generic
  252.0 KiB [          ]  config-5.13.0-28-generic
  252.0 KiB [          ]  config-5.13.0-27-generic
  252.0 KiB [          ]  config-5.13.0-25-generic
  252.0 KiB [          ]  config-5.11.0-46-generic
  184.0 KiB [          ]  memtest86+_multiboot.bin
  184.0 KiB [          ]  memtest86+.elf
  180.0 KiB [          ]  memtest86+.bin
   16.0 KiB [          ] /lost+found
    4.0 KiB [          ] /efi
    0.0   B [          ]  initrd.img.old
    0.0   B [          ]  initrd.img
    0.0   B [          ]  vmlinuz.old
    0.0   B [          ]  vmlinuz

但是,可接受的最低答案如下所示:

  100.2 MiB  /boot/initrd.img-5.13.0-28-generic         
  100.2 MiB  /boot/initrd.img-5.13.0-27-generic
   11.2 MiB  /boot/vmlinuz-5.11.0-46-generic
    9.7 MiB  /boot/vmlinuz-5.13.0-28-generic
    9.7 MiB  /boot/vmlinuz-5.13.0-27-generic
    9.7 MiB  /boot/vmlinuz-5.13.0-25-generic
    8.0 MiB  /boot/grub
    5.7 MiB  /boot/System.map-5.13.0-28-generic
    5.7 MiB  /boot/System.map-5.13.0-27-generic
    5.7 MiB  /boot/System.map-5.13.0-25-generic
    5.6 MiB  /boot/System.map-5.11.0-46-generic
  252.0 KiB  /boot/config-5.13.0-28-generic
  252.0 KiB  /boot/config-5.13.0-27-generic
  252.0 KiB  /boot/config-5.13.0-25-generic
  252.0 KiB  /boot/config-5.11.0-46-generic
  184.0 KiB  /boot/memtest86+_multiboot.bin
  184.0 KiB  /boot/memtest86+.elf
  180.0 KiB  /boot/memtest86+.bin
   16.0 KiB  /boot/lost+found
    4.0 KiB  /boot/efi
    0.0   B  /boot/initrd.img.old
    0.0   B  /boot/initrd.img
    0.0   B  /boot/vmlinuz.old
    0.0   B  /boot/vmlinuz
disk-usage ncdu
  • 3 个回答
  • 776 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve