How do I search for a term in a file?

With the grep command.

If you want to find out if the term user is in /etc/httpd/conf/httpd.conf, you would run

grep -i user /etc/httpd/conf/httpd.conf

(-i makes the search case-insensitive).

Normally grep does not tell you the line number where it finds the term. If you want to find out the line number, run

grep -n -i user /etc/httpd/conf/httpd.conf
Share this page:

0 Comment(s)