Skip to content

How to parse/reformat gtrash find output? Output not consistent #18

Description

@rieje

I want to make gtrash find --show-size --show-trashpath to be more succinct, turning from:

Date                 Size    Path                                  TrashPath
2025-07-26 10:18:53  0 B     /home/jack/zzzzzzzzzzzzzzzzz.torrent  /home/jack/.local/share/Trash/files/zzzzzzzzzzzzzzzzz.torrent
2025-07-26 11:13:07  6.7 GB  /data/vid/cat - vid.mp4               /data/.Trash-1000/files/cat - vid.mp4
2025-07-26 11:19:45  4.7 GB  /data/vid/dog - vid.mp4               /data/.Trash-1000/files/dog - vid.mp4

to

Date               Size  Path                         TrashPath
25-07-26 10:18:53    0B  ~/zzzzzzzzzzzzzzzzz.torrent  ~
25-07-26 11:13:07  6.7G  /data/vid/cat - vid.mp4      /data
25-07-26 11:19:45  4.7G  /data/vid/dog - vid.mp4      /data

Changes:

  • Make year shorter

  • Size unit is guaranteed 1 character and aligned to the right for readability (this format is typical in Linux with ls and at least terminal-based file managers like nnn)

  • /home/jack converted to ~

  • Instead of trash path, prefer simply where the trash can resides, which is generally all you need and keeps it output more concise

However, it seems with gtrash trying to be smart with its terminal detection, it doesn't seem obvious how to parse the output. For example, when I dump gtrash find --show-size --show-trashpath to a file or pipe to something like less, spacing and alignment is lost or not consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions