1

I have a directory with a bunch of images. Going there with the GUI and pressing CTRL+A (selecting all files) it counts 5058 images. Doing `ls . | wc -l files it counts 5060 files.

I have the suspsect that the "missing files" are images, otherwise a program that I'm using on it would have returned an error message (and it counts 5060 files too).

user6321
  • 175

2 Answers2

3

Hidden files can be shown using the GUI or the cli.

Using the GUI way, in Nautilus (file manager) hit ctrl+h to see all files, including the hidden files (filenames that begin with a period).

Hidden files can be metadata files, or image catalog files, or even application preferences... and they're hidden because they don't contribute to the general listing of image files that you have.

In the command line way, it's the difference between the ls command, and the ls -a command. The latter one shows the hidden files too.

heynnema
  • 73,649
0

If your ls command is aliased to ls -a or ls -A, its output includes two extra items , . and .. , which refer to directory itself . and its parent (..), as well as other files that start with leading . , so there's your difference from 5058 and 5060 files. They don't show up in GUI file manager simply because it's build that way, however most Unix applications are build to recognize the existence of those two.

Additionally, please never use ls | wc -l to count files. Parsing output of ls has a lot of issues, and it's a practice that is generally best to be avoided. If you need to count files in a directory via command line, please see Why does `ls -l` count more files than me? for proper methods.

In this specific case, I'd recommend you use find -maxdepth 1. find prints all of the files and directories, and does not hide those files or directories that begin with leading .