How to list all files on the system

command linehomebrewterminal

I would like to list all files on my system from command line.

The provided BSD find command, with the following command line

sudo find / 

lists many of the files twice, under the root and under /System/Volumes/Data.

The GNU find command, installed with Homebrew, with the following command line

sudo gfind /

does not list files under /Applications, /Users, /Volumes and others.
The command

sudo gfind /*

lists more file, but I am not sure if they are all.

I would like to list all files once and preferably with GNU find, because differently from BSD find has a -printf command with many output formats, like inode, size, separated path and filename, unified timestamp and others.

Best Answer

My best solution is the following (for bash shell)

shopt -s dotglob
for f in /* 
  sudo gfind "$f" -path /System/Volumes/Data -prune -o -print 2>/dev/null
done
shopt -u dotglob

where, in place of -print, one can use several other commands.

The most part of files in /System/Volumes/Data are the same as in /, with few and not much interesting additions.

Moreover, the more compact solution gfind /* does not work well, because produces many loops that prevent the listing of many parts of the full listing.