HACKER Q&A
📣 shivajikobardan

Should I need to use -print in a find command?


find / -type f ! -perm 0777 -print

vs

find / -type f ! -perm 0777

Both print same results.

I've seen somewhere to use -print0 but not sure why.


  👤 jeffreygoesto Accepted Answer ✓
At least for print0 I can answer. It delimits the output with zero chars instead of spaces. That is useful if you process the output with xargs (add '-0' there, see help text or man page). If your file or directory names contain spaces, they will stay together with the zero delimiter, whereas without they would be split into pieces abd xargs does not see valid file names. In a directory containing files with spaces, try both

find . -type f | xargs ls -1

find . -type f -print0| xargs -0 ls -1


👤 compressedgas
No, print is the default action. However if you use some other action such as -delete or -exec, if you want to print also, you must include the print option.