Skip to content

df: incorrect whitespace between columns in output table #3194

Closed

Description

@jfinkels

This whitespace between columns in the table produced by df does not match that of GNU df.

GNU df:

$ df | head -n4
Filesystem                1K-blocks     Used Available Use% Mounted on
udev                        3858016        0   3858016   0% /dev
tmpfs                        782624     2112    780512   1% /run
/dev/mapper/vgubuntu-root 242791844 94907344 135481608  42% /

uutils df:

$ ./target/debug/df | head -n4
Filesystem          1k-blocks         Used    Available  Use% Mounted on       
udev                  3858016            0      3858016    0% /dev            
tmpfs                  782624         2112       780512    0% /run            
/dev/mapper/vgubuntu-root    242791844     94907356    147884488   39% /  

It appears that the column width depends on the length of the largest entry in the column.

Activity

  1. crazystylus commented on Mar 1, 2022

    @crazystylus
    Contributor

    Can you run this $ ./target/debug/df | head -n4 | bat -App and share the output, so that EOL and space characters are visible?

  2. jfinkels commented on Mar 2, 2022

    @jfinkels
    CollaboratorAuthor

    What is bat -App? Maybe a Windows thing. Maybe this helps you see them:

    $ ./target/debug/df | head -n 4 | tr " " _
    Filesystem__________1k-blocks_________Used____Available__Use%_Mounted_on_______
    udev__________________3858016____________0______3858016____0%_/dev____________
    tmpfs__________________782624_________2116_______780508____0%_/run____________
    /dev/mapper/vgubuntu-root____242791844_____81529496____161262348___34%_/_______________
    $ df | head -n 4 | tr " " _
    Filesystem________________1K-blocks_____Used_Available_Use%_Mounted_on
    udev________________________3858016________0___3858016___0%_/dev
    tmpfs________________________782624_____2116____780508___1%_/run
    /dev/mapper/vgubuntu-root_242791844_81529496_148859456__36%_/
    

    You can also see the whitespace characters if you just copy the output block in my comment above and paste it into your own text editor.

  3. crazystylus commented on Mar 2, 2022

    @crazystylus
    Contributor

    What is bat -App? Maybe a Windows thing. Maybe this helps you see them:

    $ ./target/debug/df | head -n 4 | tr " " _
    Filesystem__________1k-blocks_________Used____Available__Use%_Mounted_on_______
    udev__________________3858016____________0______3858016____0%_/dev____________
    tmpfs__________________782624_________2116_______780508____0%_/run____________
    /dev/mapper/vgubuntu-root____242791844_____81529496____161262348___34%_/_______________
    $ df | head -n 4 | tr " " _
    Filesystem________________1K-blocks_____Used_Available_Use%_Mounted_on
    udev________________________3858016________0___3858016___0%_/dev
    tmpfs________________________782624_____2116____780508___1%_/run
    /dev/mapper/vgubuntu-root_242791844_81529496_148859456__36%_/
    

    You can also see the whitespace characters if you just copy the output block in my comment above and paste it into your own text editor.

    bat is cat's clone in Rust with wings, check this out https://github.com/sharkdp/bat. I will try to figure a way to pass column width without adding an entry at each row struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions