Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"--max-depth" support - allow for summary of size per directory #325

Open
sforsythe-wiley opened this issue Feb 29, 2024 · 2 comments
Open

Comments

@sforsythe-wiley
Copy link

I was hoping the output -o json would do this, but that feature appears more to save the state, to be fed back into gdu at a later time interactively.

I was hoping for the equiv of du --max-depth flag
with possible improvement of output in json format,

eg:

du -h --max-depth=0
1.2G    .

du -h --max-depth=1
1.2G    .
 92M    ./2024
863M    ./2023
305M    ./2022

du -h -max-depth=2
1.2G    .
141M    ./2022/07
31M     ./2022/08
25M     ./2022/09
41M     ./2022/10
48M     ./2022/11
20M     ./2022/12
305M    ./2022
113M    ./2023/01
355M    ./2023/02
121M    ./2023/03
49M     ./2023/04
53M     ./2023/05
18M     ./2023/06
13M     ./2023/07
6.2M    ./2023/08
20M     ./2023/09
30M     ./2023/10
55M     ./2023/11
35M     ./2023/12
863M    ./2023
14M     ./2024/01
78M     ./2024/02
92M     ./2024
@rwahyudi
Copy link

What would be the drawback of including the directory usage and file count in the json file for directory?
I think this would allow us to run jq filter and produce the above output

Example :

[
  1,
  2,
  {
    "progname": "gdu",
    "progver": "v5.29.0",
    "timestamp": 1724120998
  },
  [
    {
      "name": "/etc/audisp",
      "mtime": 1701018116,
	  "asize" : 9313,	<-----------
	  "dsize" : 20480,	<-----------
	  "items" : 4		<-----------
    },
    [
      {
        "name": "plugins.d",
        "mtime": 1701018116,
		"asize": 4971,	<-----------
		"dsize": 12288,	<-----------
		"items": 3	<-----------
      },
      {
        "name": "af_unix.conf",
        "asize": 358,
        "dsize": 4096,
        "mtime": 1557149431
      },
      {
        "name": "syslog.conf",
        "asize": 517,
        "dsize": 4096,
        "mtime": 1557149431
      }
    ],
    {
      "name": "audispd.conf",
      "asize": 246,
      "dsize": 4096,
      "mtime": 1689530538
    }
  ]
]

@sforsythe-wiley
Copy link
Author

sforsythe-wiley commented Aug 20, 2024

Yes, apologies, I didn't mean to imply the output should look the same as the du example, just the desired equivalent outcome.
Putting into the json output and using jq to filter/sort was what I was envisioning as well, sorry if didn't make that clear.

Possible caveat that maybe need to indicate a directory vs a file.
I guess you could filter on elements that contain an "items" count value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants