Special characters can be distinguished using backslash character \ . However, I want to treat full period as a normal character to operate on hidden folders. For example:
ls -lh .
It will list the current directory. However, I want to list all the hidden folders. I want it to be usable with du -h, so I know the disk space the hidden folders consumed.
Files and directories whose names start with
.are “hidden” only in the sense that (a)lsignores them by default and (b) wildcard expansion excludes them. In both cases, you can see dot files if you refer to them explicitly.*expands to all non-dot files;.*expands to all dot files.(Other tools and commands may also treat them as hidden; for example, GUI file managers like Nautilus typically don’t show dot files by default, but there’s often an option to show them.)
ls -aoverrides the special treatment of files whose names start with..ls -Alists “hidden” files and folders, but excludes.(this directory) and..(the parent directory); some versions oflsmight not support-A.The
ducommand, as far as I know, doesn’t treat dot files as hidden.du -hshould show the entire directory tree starting at the current directory. (Try it in a small directory tree to make sure yours behaves this way.)EDIT :
I’ve confirmed that at least the GNU coreutils version of
dudoesn’t treat files or directories whose names start with.specially; nothing is hidden.For example, this script:
produces this output on my system (the specific numbers depend on the nature of the file system, and are irrelevant to the current discussion):
Does that meet your requirements? If not, can you explain more clearly just what you’re looking for? Do you want to list all directories, whether their names begin with
.or not? Do you want to list only “hidden” directories? What output would you like for the directory structure created by the above script?