bash - combine find and grep into a single command -
how combine below 2 1 line without changing first one?
# find / -name sshd_config -print # grep -i <sshd_config path> permitrootlogin
i came following, don't know whether gives correct result in different cases
cat `find / -name sshd_config -print` |grep permitrootlogin
don't cat $(...)
[$()
modern replacement backticks] -- doesn't work reliably if filenames contain special characters (spaces, wildcards, etc).
instead, tell find
invoke cat
you, many filenames passed each cat
invocation possible:
find / -name sshd_config -exec cat -- '{}' + | grep permitrootlogin
...or, better, ignore cat
altogether , pass filenames grep
literally:
find / -name sshd_config -exec grep -h -e permitrootlogin -- /dev/null '{}' +
replace -h
-h
if want filenames shown.