What script would allow me to grep a keyword and print the filename containing the keyword inside the file content, for example 'Carhart' inside all .sas files in all subdirectories? I tried something like the following but it doesn't work:
(find . -name '*.sas' -prune -type f -exec grep 'Carhart' > /dev/tty) >& /dev/null
The script would satisfy two conditions
- It runs on tcsh on Solaris on SPARC-Enterprise, which is certified POSIX
- It does not generate 'Permission denied' lines on directories which I have no permission to search and/or read. ( find / -name '*.sas' -prune > /dev/tty ) > & /dev/null
( find / -name '*.sas' -prune > /dev/tty ) > & /dev/null works without reporting permission denied error, how can I modify this simple line to incorporate grep?