Find file content with grep command

I want to find the text ssl_session_cache in nginx configuration folder /etc/nginx , I know the grep command can find the text in files…

I want to find the text ssl_session_cache in nginx configuration folder /etc/nginx , I know the grep command can find the text in files, but I don’t know the command, so I search the internet and save it here.

Search text in filesgrep ssl_session_cache *
grep -r ssl_session_cache *

Search text with pipe

This is what I usually used before, I will cat the content of a file, and pipe to grep command like below:cat nginx.conf | grep ssl_session_cache

Search text with grep and find

Sometime, we can filter files with find utility, and then use the grep to search text in these files, the following command can be used:find . -name "*conf" -exec grep -H "ssl_session" {} \;


Useful resources