I want to perform checks on all files in the system. For that I need the full paths of all files in the system. My initial idea was to do something like this:
for file in $(sudo find / ); do
if [ -d $file ]; then
and so on.
But then I read that it's bad practice to process the output of find that way. What then is the correct way?
(I tried things like ls -RF | grep "/$". That, however, only gives me the directory names but I need the full path of every file, directory etc. in the system.)
find
command, and the end of the body all point to "every file (and directory)", but your test-d
andgrep /$
indicate only directories. What are you actually trying to do?[ if -d ..
example to show the various operators, it'd be clearer that you don't need a simplefind -type d