How do I search for a term in a file?

Want to support HowtoForge? Become a subscriber!
 
Submitted by admin (Contact Author) (Forums) on Mon, 2006-08-07 17:27. :: Shell

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.