Using a broad definition of \"file\" (note that it doesn\'t count hidden files and assumes that file names don\'t contain newline characters). To include hidden files (except . and ..) and avoid problems with newline characters, the canonical way is: Or recursively: Solution Using a broad definition of \"file\" (note that it doesn\'t count hidden files and assumes that file names don\'t contain newline characters). To include hidden files (except . and ..) and avoid problems with newline characters, the canonical way is: Or recursively:.