Blank lines when executing "grep | xargs" in a "find -exec"
It's failing because when the grep doesn't match, you're not passing anything to xargs.
For example:
find
gets./.htaccess
and calls your-exec
.- The
grep
doesn't match anything in the file, so it outputs nothing xargs
launchesdirname
without any arguments, and sodirname
thinks it was just misused and displays its help message.
The proper way to do this:
find . -type f -name .htaccess -exec grep -iq '^deny from all$' {} \; -printf '%h\n'