I want to see sizes of all directory including hidden directory. One command I came across was this : du -hs .[!.]*

but it is giving me error :

du: cannot access ‘.[!.]*’: No such file or directory

I can't make out what I am doing wrong.

  • 2
    The pattern you use only matches files that start with a dot. Maybe there aren't any. Apr 6, 2017 at 7:03
  • .[!.]* will match only hidden ones (be it file or a directory)... if such a file is not there, you will get this error... show a sample directory contents (files, directories, hidden ones, etc) and what output you want... find+du might be better approach
    – Sundeep
    Apr 6, 2017 at 7:04
  • @Yaron I am using bash
    – Pramod
    Apr 6, 2017 at 7:12
  • @Sundeep There are two hidden folders namely '.' and '..'. I found this using ll -a
    – Pramod
    Apr 6, 2017 at 7:14
  • @Promod Of course there are. This is absolutely basic knowledge. But your pattern demands a second character that is not a dot. Hence those two files, the directory itself and its parent, are explicitly excluded. Apr 6, 2017 at 7:43

2 Answers 2


The error you’re getting means that there is no hidden file or directory in the current directory. .[!.]* expands to match any file or directory whose name starts with “.” followed by anything but “.”; if it doesn’t match anything, it is left as is by default. So in your case, du is run with .[!.]* as its argument, instead of real file or directory names, and it produces the error message you’re seeing.

You can enable nullglob to change the shell’s behaviour here:

shopt -s nullglob

Then the shell will remove patterns which match nothing, and du will report the usage of the current directory if nothing matches (that’s its default behaviour in the absence of arguments).

To achieve what you’re after, in Bash, you should do this instead:

du -sh .[!.]*/ */

This will expand to all directories in the current directory, including hidden ones. If nullglob isn’t enabled it will still produce error messages, but you’ll see the sizes of any directory that matches.

  • This does show the result I wanted. My problem is /home is allotted 19gb but I can only make out for 1.9gb with command you have shared. I am thinking that extra space which I can't account for is taken by hidden folder. If i perform `ll -a' I can see there are two hidden folders namely '.' and '..'
    – Pramod
    Apr 6, 2017 at 7:19
  • Those represent the current directory and the parent directory respectively, they won’t help explain the discrepancy. You might have a large file in the current directory (or several), or deleted files. If you search on this site for related questions you’ll find quite a few answers to help understand where your disk usage might come from. Apr 6, 2017 at 7:20

It sounds like you want this command:

du -hsc --exclude "./.*" */ | sort -h

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.