A weird situation. I have been using this command below successfully on Ubuntu 20 and earlier to get a list of all directories with highest disk usage sorted descending:
sudo du -ah --max-depth=1 / | sort -hr
However, when I run this on a latest Ubuntu 22 server, it fails with the following error message:
du: invalid maximum depth ‘1‘
Try 'du --help' for more information.
The OS details are:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
What could be the issue ? It seems like it just doesn't like that parameter of --max-depth even though it should exist and work.
Are you sure there's no invisible character around 1
? I'm getting the error when I add a WORD JOINER after the number:
$ du -ah --max-depth=1$'\xe2\x81\xa0' / | sort -hr
du: invalid maximum depth ‘1’
Try 'du --help' for more information.