Bash – How to include hidden files in stat command

bashlinuxstat

In my code I am basically looping recursively through all files and getting the sizes using stat -c%s $i. It works well for 99% of files, however, sometimes I get an error:

stat: cannot stat '/media/root/persistence/.Trash-0/info/subory': No such file or directory

When I navigate to /media/root/persistence/ directory and type ls, the ./Trash-0 folder is not shown, so I suppose the folder itself and it's content is hidden. How can I get rid of such error message and get size of files inside?

Best Answer

try this it show all files ".*" to show hidden files and "*" to show not hidden files

stat -c%s .* *
Related Question